제출 #356076

#제출 시각아이디문제언어결과실행 시간메모리
356076parsabahrami세 명의 친구들 (BOI14_friends)C++17
0 / 100
96 ms17900 KiB
// Call my Name and Save me from The Dark #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; #define SZ(x) (int) x.size() #define F first #define S second const int N = 2e6 + 10, MOD = 1e9 + 9; int n, H[N], pw[N], base = 59; char S[N]; vector<int> R; int get(int l, int r) { if (r < l) return 0; return (H[r] - 1ll * H[l - 1] * pw[r - l + 1] % MOD + MOD) % MOD; } int main() { pw[0] = 1; for (int i = 1; i < N; i++) pw[i] = 1ll * base * pw[i - 1]; scanf("%d%s", &n, S + 1); if (n % 2 == 0) return !printf("NOT POSSIBLE\n"); for (int i = 1; i <= n; i++) { H[i] = (1ll * H[i - 1] * base % MOD + S[i] - 'A' + 1) % MOD; } for (int i = 1; i <= n; i++) { if (i > n / 2) { int h = get(1, n / 2), l = get(n / 2 + 1, i - 1), r = get(i + 1, n); int hsh = (1ll * l * pw[n - i] % MOD + r) % MOD; if (h == hsh) R.push_back(i); } else { int h = get(n / 2 + 2, n), l = get(1, i - 1), r = get(i + 1, n / 2 + 1); l = (1ll * l * pw[n / 2 - i + 1] % MOD + r) % MOD; if (h == l) R.push_back(i); } } if (!SZ(R)) printf("NOT POSSIBLE\n"); else if (SZ(R) > 1) printf("NOT UNIQUE\n"); else { int id = R[0]; for (int i = 1, j = 0; i <= n && j < n / 2; i++) { if (i == id) continue; else { printf("%c", S[i]), j++; } } } return 0; }

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

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