제출 #42977

#제출 시각아이디문제언어결과실행 시간메모리
42977BThero세 명의 친구들 (BOI14_friends)C++14
100 / 100
96 ms6572 KiB
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second typedef long long ll; using namespace std; char ans[2000005]; char t[2000005]; char s[2000005]; int n; void solve() { scanf("%d", &n); scanf("%s", s); if (n % 2 == 0) { printf("NOT POSSIBLE\n"); return; } int len = (n - 1) / 2; vector <int> vv; { int l = 0, r = len + 1; int ps = -1; for (int i = 1; i <= len; ++i) { while (s[l] != s[r]) { if (ps == -1) { ps = l; } else { ps = -2; break; } ++l; } if (ps == -2) { break; } ++l, ++r; } if (ps == -1) { ps = len; } if (0 <= ps) { vv.pb(ps); } } { int l = 0, r = len; int ps = -1; for (int i = 1; i <= len; ++i) { while (s[l] != s[r]) { if (ps == -1) { ps = r; } else { ps = -2; break; } ++r; } if (ps == -2) { break; } ++l, ++r; } if (ps == -1) { ps = n - 1; } if (0 <= ps) { vv.pb(ps); } } bool ex = 0; for (auto it : vv) { int sz = 0; for (int i = 0; i < n; ++i) { if (i != it) { t[sz++] = s[i]; } } bool ok = 1; for (int i = 0; i < len; ++i) { ok &= (t[i] == t[i + len]); } if (!ok) { continue; } if (ex) { for (int i = 0; i < len; ++i) { if (t[i] != ans[i]) { printf("NOT UNIQUE\n"); return; } } } ex = 1; for (int i = 0; i < len; ++i) { ans[i] = t[i]; } } if (!ex) { printf("NOT POSSIBLE\n"); return; } for (int i = 0; i < len; ++i) { printf("%c", ans[i]); } } int main() { #ifdef BThero freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // BThero int tt = 1; while (tt--) { solve(); } return 0; }

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

friends.cpp: In function 'void solve()':
friends.cpp:22:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
friends.cpp:23:19: 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...