제출 #373134

#제출 시각아이디문제언어결과실행 시간메모리
373134mariowong세 명의 친구들 (BOI14_friends)C++14
0 / 100
38 ms6544 KiB
#include <bits/stdc++.h> using namespace std; int n,pos1,pos2,ct,ans; string s,t,r,anss; int main(){ ios::sync_with_stdio(false); cin >> n >> s; if (n%2 == 0){ cout << "NOT POSSIBLE\n"; return 0; } for (int i=1;i<=n/2;i++){ t+=s[i]; } for (int i=n/2+1;i<n;i++){ r+=s[i]; } for (int i=0;i<n/2;i++){ if (t[i] == r[i]) ct++; } for (int i=0;i<n;i++){ if (ct == n/2){ ans++; anss=t; } if (pos1 != n/2){ if (t[pos1] == r[pos1]) ct--; t[pos1]=s[i]; if (t[pos1] == r[pos1]) ct++; pos1++; } else { if (t[pos2] == r[pos2]) ct--; r[pos2]=s[i]; if (t[pos2] == r[pos2]) ct++; pos2++; } } if (ct == n/2){ ans++; anss=t; } if (ans > 1) cout << "NOT UNIQUE\n"; else if (ans == 0) cout << "NOT POSSIBLE\n"; else cout << anss << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...