# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
945251 | Alkaser_ID | Palindromic Partitions (CEOI17_palindromic) | C++17 | 0 ms | 344 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#include <iomanip>
// cout << fixed << setprecision(9) << da;
const ll N = 5e5 + 10;
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t; cin >> t;
for (; t--;) {
string s; cin >> s;
ll n = s.length();
ll res = 1;
ll l = 0, r = n - 1;
ll hl = 0, hr = 0, hl2 = 0, hr2 = 0;
ll ph1 = 47, ph2 = 53;
ll mod1 = 1e9 + 7, mod2 = 998244353;
for (ll x = 47, y = 53; l < r;) {
hl += (s[l] - 'a' + 1) * x; hl %= mod1;
hr = (hr * 47) % mod1;
hr += (s[r] - 'a' + 1) * 47;
hl2 += (s[l] - 'a' + 1) * y; hl2 %= mod2;
hr2 = (hr2 * 53) % mod2;
hr2 += (s[r] - 'a' + 1) * 53;
if (hl == hr && hl2 == hr2) {
res += 2;
hl = hr = hl2 = hr2 = 0;
x = 47; y = 53;
}
else {
x = (x * 47) % mod1;
y = (y * 53) % mod2;
}
++l; --r;
}
cout << res << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |