Submission #113593

#TimeUsernameProblemLanguageResultExecution timeMemory
113593derpwaffle21Three Friends (BOI14_friends)C++14
0 / 100
1056 ms6488 KiB
#include <iostream> #include <cstring> using namespace std; bool isSame(string s1, string s2, int size) { for (int i = 0; i < size; i++) { if (s1[i] != s2[i]) return false; } return true; } int main() { int n; cin >> n; /* while (true) { string t; for (int i = 0; i < n - 1; i++) t += char((rand() % 26) + 65); cout << t << endl; cout << t.substr(0, int((n - 1) / 2)) << endl; cout << t.substr(int((n - 1) / 2), n - 1) << endl; cin >> t; }*/ string s; string res; int resNum = 0; cin >> s; if (n % 2 == 0) { cout << "NOT POSSIBLE" << endl; return 0; } for (int i = 0; i < n; i++) { string t = s; for (int j = i; j < n; j++) { t[j] = t[j + 1]; } /* for (int j = 0; j < n - 1; j++) cout << t[j]; cout << endl;*/ /* cout << t.substr(0, int((n - 1) / 2)) << endl; cout << t.substr(int((n - 1) / 2), n - 1) << endl;*/ if (isSame(t.substr(0, int((n - 1) / 2)), t.substr(int((n - 1) / 2), n - 1), (n - 1) / 2)) { resNum++; res = t.substr(0, int((n - 1) / 2)); } } if (resNum == 0) cout << "NOT POSSIBLE" << endl; else if (resNum > 1) cout << "NOT UNIQUE" << endl; else cout << res << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...