Submission #42642

#TimeUsernameProblemLanguageResultExecution timeMemory
42642XmtosXThree Friends (BOI14_friends)C++14
100 / 100
76 ms7660 KiB
#include <bits/stdc++.h> using namespace std; int n,cnt,cnt1; string s,s1,s2,ans; bool yes; int main() { cin >>n>>s; if (n%2==0) { cout <<"NOT POSSIBLE"; return 0; } s1=s.substr(n/2+1,n/2); s2=s.substr(0,n/2+1); for (int i=0,j=0;i<=s1.size()||j<=s2.size();i++,j++) { if (i==s1.size()) { cnt++; break; } if (s1[i]!=s2[j]) { if (i!=j) break; i--; } } if (cnt) ans=s1; s1=s.substr(0,n/2); s2=s.substr(n/2,n/2+1); if (s1==ans) goto ss; for (int i=0,j=0;i<=s1.size()||j<=s2.size();i++,j++) { if (i==s1.size()) { cnt1++; break; } if (s1[i]!=s2[j]) { if (i!=j) break; i--; } } ss: if (!cnt&&!cnt1) cout <<"NOT POSSIBLE"; else if (cnt+cnt1>1&&s1!=ans) cout <<"NOT UNIQUE"; else if (cnt1) cout<<s1; else cout <<ans; return 0; }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:16:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0,j=0;i<=s1.size()||j<=s2.size();i++,j++)
                       ^
friends.cpp:16:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0,j=0;i<=s1.size()||j<=s2.size();i++,j++)
                                     ^
friends.cpp:18:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (i==s1.size())
              ^
friends.cpp:36:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0,j=0;i<=s1.size()||j<=s2.size();i++,j++)
                       ^
friends.cpp:36:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0,j=0;i<=s1.size()||j<=s2.size();i++,j++)
                                     ^
friends.cpp:38:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (i==s1.size())
              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...