Submission #42598

#TimeUsernameProblemLanguageResultExecution timeMemory
42598HassoonyThree Friends (BOI14_friends)C++14
0 / 100
84 ms5460 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=""; for(auto pp:s){ if(fr[pp]%2)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:31:17: warning: array subscript has type 'char' [-Wchar-subscripts]
         if(fr[pp]%2)continue;
                 ^
friends.cpp:32: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...