제출 #18632

#제출 시각아이디문제언어결과실행 시간메모리
18632mindol세 명의 친구들 (BOI14_friends)C++14
0 / 100
112 ms54440 KiB
#include<iostream> #include<string> using namespace std; const int mod=1e9+7; int len; string s,a,b; int f(int st,bool use) { if(st==b.size()) { if(!use) return 1; else return a[st]==b[st-1]; } int res=use?0:f(st+1,true); if(a[st]!=b[st-use]) return res; else return f(st+1,use)+res; } int main() { cin>>len>>s; if(!(len&1) || len==1) { cout<<"NOT POSSIBLE"; return 0; } a=s.substr(0,len/2+1); b=s.substr(len/2+1,len/2); int cnt1=f(0,false); a=s.substr(len/2,len/2+1); b=s.substr(0,len/2); int cnt2=f(0,false); if(s.substr(0,len/2) == s.substr(len/2+1,len/2)) cnt2--; if(cnt1+cnt2==0) cout<<"NOT POSSIBLE"; else if(cnt1+cnt2>=2) cout<<"NOT UNIQUE"; else cout<<(cnt1?s.substr(len/2+1,len/2):s.substr(0,len/2)); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...