제출 #1097610

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
10976102024-10-07 15:59:49duckindog회문 (APIO14_palindrome)C++17
8 / 100
1075 ms20184 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 300'000 + 10;
string s;
int n;
using ull = unsigned long long;
const int base = 19937;
ull h[N], rh[N], pw[N];
void initHash() {
pw[0] = 1;
for (int i = 1; i <= n; ++i) {
h[i] = h[i - 1] * base + s[i];
pw[i] = pw[i - 1] * base;
}
reverse(s.begin() + 1, s.end());
for (int i = 1; i <= n; ++i) rh[i] = rh[i - 1] * base + s[i];
reverse(s.begin() + 1, s.end());
}
ull get(int l, int r) { return h[r] - h[l - 1] * pw[r - l + 1]; }
ull rget(int l, int r) {
tie(l, r) = make_pair(n - r + 1, n - l + 1);
return rh[r] - rh[l - 1] * pw[r - l + 1];
}
bool chk(int l, int r) { return get(l, r) == rget(l, r); }
unordered_map<ull, long long> cnt;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...