Submission #236408

#TimeUsernameProblemLanguageResultExecution timeMemory
236408kaplanbarThree Friends (BOI14_friends)C++14
0 / 100
1090 ms9272 KiB
// In the name of God #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; cin >> s; if(n % 2 == 0) { cout << "NOT POSSIBLE"; exit(0); } int ans = 0; for(int i = 0; i < n; i++) { string tmp = ""; if(i == 0) tmp = s.substr(i+1, n-1); else tmp = s.substr(0, i) + s.substr(i+1, n - i - 1); if(tmp.substr(0, tmp.length()/2) == tmp.substr(tmp.length()/2, tmp.length()/2)) ans++; } if(ans == 0) cout << "NOT POSSIBLE"; if(ans > 1) cout << "NOT UNIQUE"; if(ans == 1) { for(int i = 0; i < n; i++) { string tmp = ""; if(i == 0) tmp = s.substr(i+1, n-1); else tmp = s.substr(0, i) + s.substr(i+1, n - i - 1); if(tmp.substr(0, tmp.length()/2) == tmp.substr(tmp.length()/2, tmp.length()/2)) { cout << tmp.substr(0, tmp.length() / 2); exit(0); } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...