Submission #42599

#TimeUsernameProblemLanguageResultExecution timeMemory
42599HassoonyThree Friends (BOI14_friends)C++14
0 / 100
85 ms6484 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,fr[MX],sum; string s; int main(){ cin>>n>>s; if(n%2==0){ puts("NOT POSSIBLE"); return 0; } for(auto pp:s)fr[pp]++; for(int i='A';i<='Z';i++){ if(fr[i]%2)sum++; } if(sum!=1){ puts("NOT POSSIBLE"); return 0; } sum=0; int len=(n-1)/2; string ret="",ret1=""; bool b=0; for(auto pp:s){ if(fr[pp]%2&&!b){b=1;continue;} if(ret.size()!=len)ret+=pp; else ret1+=pp; } if(ret!=ret1){ puts("NOT POSSIBLE"); return 0; } for(int i='A';i<='Z';i++){ if(fr[i]%2){ if(fr[i]!=1){ puts("NOT UNIQUE"); return 0; } } } cout<<ret<<endl; }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:19:24: warning: array subscript has type 'char' [-Wchar-subscripts]
     for(auto pp:s)fr[pp]++;
                        ^
friends.cpp:32:17: warning: array subscript has type 'char' [-Wchar-subscripts]
         if(fr[pp]%2&&!b){b=1;continue;}
                 ^
friends.cpp:33:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(ret.size()!=len)ret+=pp;
                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...