제출 #107068

#제출 시각아이디문제언어결과실행 시간메모리
107068Pajaraja세 명의 친구들 (BOI14_friends)C++17
100 / 100
133 ms6304 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin>>n>>s; if(n%2==0) {cout<<"NOT POSSIBLE"; return 0;} int p=n/2; bool sm=true; for(int i=0;i<p;i++) if(s[i]!=s[p+1+i]) sm=false; int tp=0,td=0; for(int i=0;i<p && tp<=1;i++) while(s[i]!=s[i+p+tp] && tp<=1) tp++; for(int i=n-1;i>=n-p && td<=1;i--) while(s[i]!=s[i-p-td] && td<=1) td++; if(sm) {for(int i=0;i<p;i++) cout<<s[i]; return 0;} if(tp>1 && td>1) {cout<<"NOT POSSIBLE"; return 0;} if(tp<=1 && td<=1) {cout<<"NOT UNIQUE"; return 0;} if(td>1) {for(int i=0;i<p;i++) cout<<s[i]; return 0;} for(int i=p+1;i<n;i++) cout<<s[i]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...