Submission #42602

#TimeUsernameProblemLanguageResultExecution timeMemory
42602HassoonyThree Friends (BOI14_friends)C++14
100 / 100
101 ms7728 KiB
#include<bits/stdc++.h> #include<unordered_map> #define F first #define S second using namespace std; typedef long long ll; typedef long double D; const ll inf=(1ll<<61); const ll mod=1e9+7; const int MX=1309; int n,sum; string s,ret,s1,s2; int main(){ cin>>n>>s; if(n%2==0){ puts("NOT POSSIBLE"); return 0; } for(int i=0;i<n/2;i++)s1+=s[i]; for(int i=n/2+1;i<n;i++)s2+=s[i]; if(s1==s2){ cout<<s1<<endl; return 0; } int f1=0,f2=0,j=0; for(int i=0;i<n;i++){ if(s[i]==s1[j])j++; if(j==n/2){ f1++; j=0; } } j=0; for(int i=0;i<n;i++){ if(s[i]==s2[j])j++; if(j==n/2){ f2++; j=0; } } if(f1==2&&f2==2){ puts("NOT UNIQUE"); return 0; } if(f1==2){ cout<<s1<<endl; return 0; } if(f2==2){ cout<<s2<<endl; return 0; } puts("NOT POSSIBLE"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...