Submission #105657

#TimeUsernameProblemLanguageResultExecution timeMemory
105657samsThree Friends (BOI14_friends)C++14
0 / 100
1060 ms4280 KiB
#include <bits/stdc++.h> using namespace std; int n; string u; map<char, int> ct; int main() { cin >> n >> u; if(n % 2 == 0) { cout << "NOT POSSIBLE\n"; return 0; } for(int i = 0 ; i < n ; ++i) { ct[u[i]]++; } int ii = 0; char rep = '.'; for(auto it: ct) { if(it.second%2 == 1) ii++, rep = it.first; } if(ii > 1) { cout << "NOT POSSIBLE\n"; return 0; } int cont = 0, pos = -1; //vector<int> pos; int mid = n/2; for(int i = 0 ; i < n ; ++i) { bool ok = true; int a = 0, b; if(i <= mid) b = mid + 1; else b = mid; for(int c = 1; c <= mid ; ++c, a++, b++) { if(a == i) a++; if(b == i) b++; if(u[a] != u[b]) { ok = false; break; } } if(ok == true) { cont++; pos = i; } } if(cont == 0){ cout << "NOT POSSIBLE\n"; }else if(cont == 1) { u.erase(u.find(u[pos]), u.find(u[pos])-1); for(int i = 0 ; i < mid ; ++i) cout << u[i]; cout << "\n"; }else{ cout << "NOT UNIQUE\n"; } return 0; }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:23:7: warning: variable 'rep' set but not used [-Wunused-but-set-variable]
  char rep = '.';
       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...