Submission #26458

#TimeUsernameProblemLanguageResultExecution timeMemory
26458noobprogrammerThree Friends (BOI14_friends)C++14
0 / 100
19 ms7880 KiB
#include <bits/stdc++.h> using namespace std ; #define fi first #define se second #define ii pair<int,int> #define vi vector<int> #define vii vector<ii> char s[2000010] , pt[2000010] , sf[2000010] ; int n , m ; int main(){ // freopen("in.txt" , "r" , stdin) ; scanf("%d%s" , &n , s ); if(n%2 == 0){ printf("NOT POSSILBLE") ;return 0 ; } bool c1 = 1 , c2 = 1 ; // front m = n/2 ; for(int i=0;i<m;i++) pt[i] = s[i] ; for(int i=m;i<n;i++){ if(i>m) c2 = (c1) || (c2 && (s[i] == pt[i-m-1])) ; c1 = c1 && (s[i] == pt[i-m]) ; } bool r1 = c2 , r2 ; for(int i=m+1;i<n;i++) sf[i-m-1] = s[i] ; c1 = 1 , c2 = 1 ; for(int i=0;i<=m;i++){ if(i) c2 = (c1) || (c2&&(s[i] == sf[i-1]) ) ; c1 = c1&&(s[i] == sf[i]) ; } r2 = c2 ; // printf("%d %s %d %s\n" ,r1 , pt , r2 , sf ) ; if(r1 && r2){ c1 = 1 ; for(int i=0;i<m;i++) if(sf[i] != pt[i]) c1= 0 ; if(c1) printf("%s", pt); else printf("NOT UNIQUE") ; } else if(r1){ printf("%s" , pt) ; } else if(r2){ printf("%s" , sf) ; } else{ printf("NOT POSSIBLE") ; } }

Compilation message (stderr)

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