Submission #203455

#TimeUsernameProblemLanguageResultExecution timeMemory
203455mdn2002Three Friends (BOI14_friends)C++14
0 / 100
126 ms12264 KiB
#include<bits/stdc++.h> using namespace std; int n; string a,x,ox,y,oy; int main() { cin>>n>>a; if(n%2==0) { cout<<"NOT POSSIBLE"; return 0; } for(int i=0;i<n/2;i++)x.push_back(a[i]); for(int i=(n/2)+1;i<n;i++)y.push_back(a[i]); ox=x; oy=y; x+=x; y+=y; int cnt=0,aa=0,bb=0; for(int i=0,j=0;i<n,j<n-1;i++) { if(a[i]==x[j])j++; else cnt++; if(cnt>1)break; if(i==n-1)aa++; } cnt=0; for(int i=0,j=0;i<n,j<n-1;i++) { if(a[i]==y[j])j++; else cnt++; if(cnt>1)break; if(i==n-1)bb++; } if(aa+bb==0) { cout<<"NOT POSSIBLE"; return 0; } if(aa+bb==2) { cout<<"NOT UNIQUE"; return 0; } if(aa)cout<<ox; if(bb)cout<<oy; }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:20:22: warning: left operand of comma operator has no effect [-Wunused-value]
     for(int i=0,j=0;i<n,j<n-1;i++)
                     ~^~
friends.cpp:28:22: warning: left operand of comma operator has no effect [-Wunused-value]
     for(int i=0,j=0;i<n,j<n-1;i++)
                     ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...