Submission #103449

#TimeUsernameProblemLanguageResultExecution timeMemory
103449pedro_sponchiadoThree Friends (BOI14_friends)C++17
0 / 100
23 ms9216 KiB
#include<bits/stdc++.h> using namespace std; const int maxn=2000010; int n_, n; char str[maxn], s1[maxn], s2[maxn], s3[maxn], s4[maxn]; int verif(char str1[maxn], char str2[maxn]){ int mini; for(int i=0; i<=n; i++){ if(str1[i]!=str2[i]){ mini=i; break; } } // printf("mini=%d\n", mini); int cont=0, da=1; for(int i=0; i<n; i++){ if(cont==mini) cont++; // printf("%c %c\n", str1[i], str2[cont]); if(str1[i]!=str2[cont]) da=0; cont++; } // printf("%d\n", da); if(da==0) return 0; if( (str2[mini]==str2[mini-1] && mini>=1) || (str2[mini]==str2[mini+1] && mini<=n-1) ) return 2; return 1; } int main(){ scanf("%d", &n_); scanf(" %s ", &str); if(n_%2==0){ printf("NOT POSSIBLE\n"); return 0; } n=n_/2; for(int i=0; i<n; i++) s1[i]=str[i]; for(int i=n; i<=2*n; i++) s2[i-n]=str[i]; for(int i=n+1; i<=2*n; i++) s3[i-n-1]=str[i]; for(int i=0; i<=n; i++) s4[i]=str[i]; int x=verif(s1, s2)+verif(s3, s4); // printf("%s %s %s %s\n", s1, s2, s3, s4); if(x==0) printf("NOT POSSIBLE\n"); if(x==1){ if(verif(s1, s2)) printf("%s\n", s1); else printf("%s\n", s3); } if(x>=2) printf("NOT UNIQUE\n"); return 0; }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:32:20: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[2000010]' [-Wformat=]
  scanf(" %s ", &str);
                ~~~~^
friends.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n_);
  ~~~~~^~~~~~~~~~~
friends.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %s ", &str);
  ~~~~~^~~~~~~~~~~~~~
friends.cpp: In function 'int verif(char*, char*)':
friends.cpp:26:32: warning: 'mini' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if( (str2[mini]==str2[mini-1] && mini>=1) || (str2[mini]==str2[mini+1] && mini<=n-1) ) return 2;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...