제출 #47419

#제출 시각아이디문제언어결과실행 시간메모리
47419win11905세 명의 친구들 (BOI14_friends)C++11
0 / 100
62 ms34884 KiB
#include <bits/stdc++.h> #define pii pair<int, int> #define x first #define y second using namespace std; // I will use hsh 107, 109 const int N = 2e6+5, M = 1e9+7; int n, st; char A[N]; pii hsh[N], pw[N], iden(107, 109); pii add(pii a, pii b) { return pii(a.x + b.x, a.y + b.y); } pii mul(pii a, pii b) { return pii(a.x * b.x, a.y * b.y); } pii sub(pii a, pii b) { return pii(a.x - b.x, a.y - b.y); } int main() { scanf("%d", &n); if(n % 2 == 0) return puts("NOT POSSIBLE") & 0; scanf("%s", A+1); st = n >> 1; for(int i = 1; i <= n; ++i) hsh[i] = add(mul(hsh[i-1], iden), pii(A[i], A[i])); pw[0] = pii(1, 1); for(int i = 1; i <= n; ++i) pw[i] = mul(pw[i-1], iden); vector<pii> V; for(int i = 1; i <= n; ++i) { pii hshl, hshr; if(i <= st) { hshl = add(mul(hsh[i-1], pw[st-i+1]), sub(hsh[st+1], mul(hsh[i], pw[st-i+1]))); hshr = sub(hsh[n], mul(hsh[st+1], pw[st])); if(hshl == hshr) V.emplace_back(st+2, n); } else { hshl = hsh[st]; hshr = add(sub(hsh[n], mul(hsh[i], pw[n-i])), mul(sub(hsh[i-1], mul(hsh[st], pw[i-st-1])), pw[n-i])); if(hshl == hshr) V.emplace_back(1, st); } } if(V.size() == 0) puts("NOT POSSIBLE"); if(V.size() == 1) A[V[0].y+1] = 0, puts(A+V[0].x); if(V.size() > 1) puts("NOT UNIQUE"); }

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

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