제출 #930729

#제출 시각아이디문제언어결과실행 시간메모리
930729emptypringlescan세 명의 친구들 (BOI14_friends)C++17
100 / 100
12 ms8196 KiB
#include <bits/stdc++.h> using namespace std; int32_t main(){ ios::sync_with_stdio(0);cin.tie(0); int n; cin >> n; if(n%2==0||n<3){ cout << "NOT POSSIBLE"; return 0; } string s; cin >> s; set<string> ans; string a="",b=""; int mid=n/2; for(int i=mid+1; i<n; i++) a+=s[i]; int p1,p2; for(p1=0; p1<mid; p1++){ if(s[p1]!=a[p1]) break; } for(p2=mid; p2>0; p2--){ if(s[p2]!=a[p2-1]) break; } if(p1>=p2) ans.insert(a); for(int i=0; i<mid; i++) b+=s[i]; for(p1=mid; p1<n-1; p1++){ if(s[p1]!=b[p1-mid]) break; } for(p2=n-1; p2>mid; p2--){ if(s[p2]!=b[p2-1-mid]) break; } if(p1>=p2) ans.insert(b); if(ans.size()>1) cout << "NOT UNIQUE"; else if(ans.size()==1) cout << *ans.begin(); else cout << "NOT POSSIBLE"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...