Submission #42597

#TimeUsernameProblemLanguageResultExecution timeMemory
42597HassoonyThree Friends (BOI14_friends)C++14
0 / 100
72 ms4576 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=309; 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; for(int i='A';i<='Z';i++){ if(fr[i]%2){ if(fr[i]!=1){ puts("NOT UNIQUE"); return 0; } } } int len=(n-1)/2; string ret=""; for(auto pp:s){ if(fr[pp]%2||ret.size()==len)continue; ret+=pp; } 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:39:17: warning: array subscript has type 'char' [-Wchar-subscripts]
         if(fr[pp]%2||ret.size()==len)continue;
                 ^
friends.cpp:39:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(fr[pp]%2||ret.size()==len)continue;
                                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...