제출 #27479

#제출 시각아이디문제언어결과실행 시간메모리
27479TAMREF세 명의 친구들 (BOI14_friends)C++11
100 / 100
6 ms3972 KiB
#include <bits/stdc++.h> using namespace std; const int mx=2e6+10; int n,h; char S[mx]; void nu(){exit(0*puts("NOT UNIQUE"));} void np(){exit(0*puts("NOT POSSIBLE"));} void input(){ scanf("%d\n",&n); if(n%2==0) np(); fgets(S,mx-4,stdin); S[n]=0; h=(n-1)>>1; } void solve(){ int i,cnt=0; for(i=0;i<h&&S[i]==S[i+h];i++); for(;i<h&&S[i]==S[i+h+1];i++); if(i==h) cnt|=1; for(i=0;i<h&&S[i]==S[i+h+1];i++); for(;i<h&&S[i+1]==S[i+h+1];i++); if(i==h) cnt|=2; S[h]=0; switch(cnt){ case 0: np(); case 1: exit(0*puts(S)); case 3: if(strcmp(S,S+h+1)) nu(); case 2: exit(0*puts(S+h+1)); } } int main(){ input(); solve(); }

컴파일 시 표준 에러 (stderr) 메시지

friends.cpp: In function 'void input()':
friends.cpp:9:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d\n",&n);
                     ^
friends.cpp:11:24: warning: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     fgets(S,mx-4,stdin);
                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...