Submission #550106

#TimeUsernameProblemLanguageResultExecution timeMemory
550106ToroTNThree Friends (BOI14_friends)C++14
100 / 100
49 ms5248 KiB
#include<bits/stdc++.h> using namespace std; int n,m,l,r,cnt,st,ed,krit; char s[2000005]; int main() { scanf("%d",&n); scanf("%s",s+1); m=n/2; if(n%2==0) { printf("NOT POSSIBLE\n"); return 0; } l=1; r=m+1; cnt=0; while(l<=m&&r<=n) { if(s[l]==s[r]) { ++l,++r; }else { ++r; ++cnt; } } if(cnt<=1) { st=1; } l=1; r=m+2; cnt=0; while(l<=m+1&&r<=n) { if(s[l]==s[r]) { ++l,++r; }else { ++l; ++cnt; } } if(cnt<=1) { ed=1; } if(st==1&&ed==1) { krit=0; for(int i=1;i<=m;i++) { if(s[i]==s[i+m+1])++krit; } if(krit==m) { for(int i=1;i<=m;i++) { printf("%c",s[i]); } printf("\n"); }else { printf("NOT UNIQUE\n"); } }else if(st==1) { for(int i=1;i<=m;i++) { printf("%c",s[i]); } printf("\n"); }else if(ed==1) { for(int i=m+2;i<=n;i++) { printf("%c",s[i]); } printf("\n"); }else { printf("NOT POSSIBLE\n"); } }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
friends.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%s",s+1);
      |     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...