제출 #535140

#제출 시각아이디문제언어결과실행 시간메모리
535140__Variatto세 명의 친구들 (BOI14_friends)C++17
0 / 100
1087 ms4336 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define ll long long const int MAX=2e3; int n; string s; bool sa(int x){ int l, p; if(x<n/2+1) l=1, p=n/2+2; else l=1, p=n/2+1; if(l==x) l++; if(p==x) p++; for(int i=1; i<=n/2; i++){ if(s[l]!=s[p]) return false; l++, p++; if(l==x) l++; if(p==x) p++; } return true; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin>>n>>s; if(n%2==0){ cout<<"NOT POSSIBLE\n"; return 0; } s='%'+s ; int ile=0, wyn; for(int i=1;i<=n; i++){ if(sa(i)) ile++, wyn=i; } if(!ile) cout<<"NOT POSSIBLE\n"; else if(ile>1) cout<<"NOT UNIQUE\n"; else{ int xd=0; for(int i=1; i<=n; i++){ if(i!=wyn){ cout<<s[i]; xd++; } if(xd==n/2) break; } cout<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...