제출 #615373

#제출 시각아이디문제언어결과실행 시간메모리
615373Hanksburger세 명의 친구들 (BOI14_friends)C++17
100 / 100
13 ms10100 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, cnt=0; string s, a, b; cin >> n >> s; if (n%2==0) { cout << "NOT POSSIBLE"; return 0; } if (s.substr(0, n/2)==s.substr(n/2, n/2) && s.substr(1, n/2)==s.substr(n/2+1, n/2) && s.substr(0, n/2)!=s.substr(1, n/2)) { cout << "NOT UNIQUE"; return 0; } a=s.substr(1, n/2); b=s.substr(n/2+1, n/2); for (int i=0; i<n/2; i++) if (a[i]!=b[i]) cnt++; if (!cnt) { cout << a; return 0; } for (int i=0; i<n/2; i++) { if (a[i]!=b[i]) cnt--; a[i]=s[i]; if (a[i]!=b[i]) cnt++; if (!cnt) { cout << a; return 0; } } for (int i=0; i<n/2; i++) { if (a[i]!=b[i]) cnt--; b[i]=s[n/2+i]; if (a[i]!=b[i]) cnt++; if (!cnt) { cout << a; return 0; } } cout << "NOT POSSIBLE"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...