제출 #26466

#제출 시각아이디문제언어결과실행 시간메모리
26466WhipppedCream세 명의 친구들 (BOI14_friends)C++14
100 / 100
79 ms3972 KiB
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define pb push_back #define mp make_pair typedef pair<int, int> ii; typedef vector<int> vi; typedef vector< ii > vii; typedef long long L; typedef vector< L > vL; typedef vector< vL > vvL; typedef vector< vi > vvi; typedef vector< vii > vvii; const int inf = 1e9; const L inf8 = 1e18; const int maxn = 2e6 + 5; const int md = 1e9 + 7; void np() { puts("NOT POSSIBLE"); exit(0); } void nu() { puts("NOT UNIQUE"); exit(0); } char s[maxn]; int main() { int n; scanf("%d", &n); scanf("%s", s); if(n%2 == 0 || n<= 2) np(); int a = 0, b = 0; int skipped = 0; int ptr = n/2; bool bad = 0; for(int i = 0; i< n/2; i++) { if(s[i] == s[ptr]) ptr++; else if(!skipped) { skipped = 1; i--; ptr++; } else { bad = 1; break; } } if(!bad) a = 1; skipped = 0; bad = 0; ptr = 0; for(int i = n/2+1; i< n; i++) { if(s[i] == s[ptr]) ptr++; else if(!skipped) { skipped = 1; i--; ptr++; } else { bad = 1; break; } } bool same = 1; for(int i = 0; i< n/2; i++) if(s[i] != s[n/2+i+1]) same = 0; if(!bad) b = 1; if(a&&b && !same) nu(); if(a+b == 0) np(); if(a) for(int i = 0; i< n/2; i++) printf("%c", s[i]); else for(int i = n/2+1; i< n; i++) printf("%c", s[i]); return 0; }

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

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