Submission #742006

#TimeUsernameProblemLanguageResultExecution timeMemory
742006MODDIThree Friends (BOI14_friends)C++14
100 / 100
53 ms6164 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair typedef long long ll; typedef pair<long long, long long> pll; typedef pair<int,int> pii; typedef vector<long long> vl; typedef vector<int> vi; int n; string str; int main(){ cin>>n>>str; string one, two; int i, t; if(n%2 == 0){ cout<<"NOT POSSIBLE"<<endl; return 0; } for(i = 0; i < n/2; i++) if(str[i] != str[i+n/2]) break; t = i; for(i = n/2-1; i>= 0; i--) if(str[i] != str[i+n/2+1]) break; int flag; if(t > i) flag = 1; else flag = 0; for(i = 0; i < n/2+1; i++) if(str[i] != str[i+n/2+1]) break; t = i; for(i = n/2; i >= 0; i--) if(str[i] != str[i+n/2]) break; if(t >= i){ if(flag){ for(i = 0; i < n/2; i++) if(str[i] != str[i+n/2+1]) break; if(i == n/2){ string out; for(i = 0; i < n/2; i++) out.pb(str[i]); cout<<out<<endl; } else cout<<"NOT UNIQUE"<<endl; } else{ string out; for(i = 0; i <n/2; i++) out.pb(str[i+n/2+1]); cout<<out<<endl; } } else{ if(flag){ string out; for(i = 0; i < n/2; i++) out.pb(str[i]); cout<<out<<endl; } else cout<<"NOT POSSIBLE"<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...