제출 #697437

#제출 시각아이디문제언어결과실행 시간메모리
697437Deepesson세 명의 친구들 (BOI14_friends)C++17
100 / 100
32 ms5356 KiB
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); int N; std::cin>>N; if(!(N&1)){ std::cout<<"NOT POSSIBLE\n"; return 0; } int size = (N-1)/2; std::string s; std::cin>>s; int skips[2]={}; int cur1=0,cur2=N-size; while(cur2!=N){ if(s[cur1]==s[cur2]){ ++cur1; ++cur2; }else { ++skips[0]; if(skips[0]==2){ break; } ++cur1; } } if(cur1!=size+1)skips[0]++; cur1=N-size-1,cur2=0; while(cur2!=size){ if(s[cur1]==s[cur2]){ ++cur1; ++cur2; }else { ++skips[1]; if(skips[1]==2){ break; } ++cur1; } } if(cur1!=N)skips[1]++; //std::cout<<skips[0]<<" "<<skips[1]<<"\n"; if(skips[0]>1&&skips[1]>1){ std::cout<<"NOT POSSIBLE\n"; return 0; }else if(skips[0]<2&&skips[1]<2){///caso especial: ambas as strings sao iguais int cur1=0,cur2=N-size; while(cur2!=N){ if(s[cur1]!=s[cur2]){ std::cout<<"NOT UNIQUE\n"; return 0; } ++cur1; ++cur2; } for(int i=0;i!=size;++i){ std::cout<<s[i]; } std::cout<<"\n"; }else { if(skips[1]<2){ for(int i=0;i!=size;++i){ std::cout<<s[i]; } std::cout<<"\n"; }else { for(int i=N-size;i!=N;++i){ std::cout<<s[i]; } std::cout<<"\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...