Submission #423002

#TimeUsernameProblemLanguageResultExecution timeMemory
423002victoriadThree Friends (BOI14_friends)C++14
0 / 100
11 ms4208 KiB
#include <cmath> #include <cstdio> #include <iostream> #include <algorithm> #include <utility> #include <vector> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); int n; string s; cin>>n>>s; if(n%2==0){ cout<<"NOT POSSIBLE"; } else{ int l=0; int us=-1; vector<char> a; int x,y; for(int i=0;i<n/2;i++){ if(s[i]==s[i+n/2]||s[i]==s[i+n/2+1]){ a.push_back(s[i]); } else{ if(l==0){ l=1; } else{ l++; cout<<"NOT POSSIBLE"; break; } } } if(l<=1){ if(s[n/2]!=s[0] && s[n/2]==s[n-1])a.push_back(s[n/2]); int y=-1; if(l==0){ for(int i=n/2;i<n-1;i++){ if(s[i]==s[i+1]){ y=0; break; } } if(s[0]==s[n-1]&& s[0]==s[n/2])y=0; } else{ for(int i=0;i<n/2;i++){ if(s[i]==s[i+1]){ y=0; break; } } } if((s[n/2]==s[0] && s[n/2]==s[n/2+1]&& s[n/2]!=s[n-1] && l==0)||y==0){ cout<<"NOT UNIQUE"; } else if(a.size()!=n/2){ cout<<"NOT POSSIBLE"; } else{ for(int i=0;i<a.size();i++){ cout<<a[i]; } } } } }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:60:19: warning: comparison of integer expressions of different signedness: 'std::vector<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |   else if(a.size()!=n/2){
      |           ~~~~~~~~^~~~~
friends.cpp:64:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |    for(int i=0;i<a.size();i++){
      |                ~^~~~~~~~~
friends.cpp:19:7: warning: unused variable 'us' [-Wunused-variable]
   19 |   int us=-1;
      |       ^~
friends.cpp:21:7: warning: unused variable 'x' [-Wunused-variable]
   21 |   int x,y;
      |       ^
friends.cpp:21:9: warning: unused variable 'y' [-Wunused-variable]
   21 |   int x,y;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...