Submission #41125

#TimeUsernameProblemLanguageResultExecution timeMemory
4112514kgThree Friends (BOI14_friends)C++11
100 / 100
75 ms19636 KiB
#include <stdio.h> #define N 2000005 int n, link[N]; char in[N]; int main(){ int scnt=0, out=0, len=0; scanf("%d %s",&n,in+1); if(n%2==0){ printf("NOT POSSIBLE"); return 0; } for(int i=2; i<=n/2+1; i++){ int j=n/2+i; scnt+=(in[i]==in[j]); link[i]=j, link[j]=i; } if(scnt==n/2) out=1; for(int i=2; i<=n; i++){ int x=i-1, y=link[i]; scnt-=(in[i]==in[y]); link[x]=y, link[y]=x; scnt+=(in[x]==in[y]); if(scnt==n/2 && out){ if(out==i-1 && in[i-1]==in[i]) out++; else{ printf("NOT UNIQUE"); return 0; } } else if(scnt==n/2) out=i; } if(!out){ printf("NOT POSSIBLE"); return 0; } for(int i=1; len<n/2; i++){ if(i==out) continue; len++, printf("%c",in[i]); } }

Compilation message (stderr)

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