제출 #85903

#제출 시각아이디문제언어결과실행 시간메모리
85903igzi세 명의 친구들 (BOI14_friends)C++17
0 / 100
71 ms4356 KiB
#include <bits/stdc++.h> #define maxN 200005 using namespace std; string s; unsigned long long h[maxN],p[maxN],t,tmp,pom,n,i,ans; vector <unsigned long long> v; int main() { cin>>n; cin>>s; if(n%2==0) {cout<<"NOT POSSIBLE"<<endl; return 0;} h[0]=s[0]-'A'+1; p[0]=1; for(i=1;i<maxN;i++){p[i]=27*p[i-1];} return 0; t=(n-1)/2; for(i=0;i<n;i++){ if(i<t){ if(i>0) tmp=p[t+1]*(h[i-1])+p[t]*(h[t]-h[i]); else tmp=p[t]*(h[t]-h[0]); pom=h[n-1]-h[t]; if(tmp==pom && (v.empty() || v[0]!=tmp)) {v.push_back(tmp); ans=i;} } else{ if(i<n-1) tmp=27*(h[i-1]-h[t-1])+(h[n-1]-h[i]); else tmp=27*(h[n-2]-h[t-1]); pom=p[t+1]*h[t-1]; if(tmp==pom && (v.empty() || v[0]!=tmp)) {v.push_back(tmp); ans=i;} } if(v.size()>1) {cout<<"NOT UNIQUE"<<endl; return 0;} } if(v.size()==0) {cout<<"NOT POSSIBLE"<<endl; return 0;} for(i=0;i<t;i++){if(ans!=i) cout<<s[i];} if(ans<t) cout<<s[t]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...