#include #include #include #include using namespace std; /* * Author * Robin Lee (hex539) * * Algorithm * Search for one clock's difference string in the other by duplicating the * latter and running an implementation of strstr(). The difference from a * correct solution is that this one uses basic_string::find, which is O(MN) * in the worst case. * * Complexity * O(N^2) */ basic_string read_clock(int n){ int const modulo = 360000; vector v(n); for (int i=0; i>v[i]; sort(v.begin(),v.end()); v.push_back(v.front()); basic_string s; for (int i=0; i>n; basic_string a=read_clock(n), b=read_clock(n); cout<<((b+b).find(a) != string::npos? "possible": "impossible")<