Submission #44298

#TimeUsernameProblemLanguageResultExecution timeMemory
44298ista2000Three Friends (BOI14_friends)C++17
100 / 100
14 ms5780 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int const int mod = 1e9+7; #undef int int main() { #define int long long int ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; string s; cin>>s; if(!(n&1)) { cout<<"NOT POSSIBLE"<<endl; return 0; } int c = n/2, skip = 0; bool poss = true;string ans1 = "", ans2 = ""; for(int i = 0;i<n/2;i++, c++) { if(s[i]!=s[c]) { if(skip) { poss = false; break; } skip++; i--; } } if(poss) ans1 = s.substr(0, n/2); poss = true; c = 0, skip = 0; for(int i = n/2+1;i<n;i++, c++) { if(s[i]!=s[c]) { if(skip) { poss = false; break; } skip++; i--; } } if(poss) ans2 = s.substr(n/2+1); if(ans1!=""&&ans2!=""&&ans1!=ans2) cout<<"NOT UNIQUE"<<endl; else if(ans1!="") cout<<ans1<<endl; else if(ans2!="") cout<<ans2<<endl; else cout<<"NOT POSSIBLE"<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...