| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 199681 | rKrPaN | Palindromic Partitions (CEOI17_palindromic) | C++98 | 568 ms | 19148 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <string>
using namespace std;
long long H[1000100];
long long pot[1000100];
long long h(int l, int d){
l++; d++;
return H[d] - H[l-1] * pot[d-l+1];
}
int main(){
int t;
cin >> t;
for (int ij = 0; ij < t; ij++){
string s;
cin >> s;
int n = s.size();
H[1] = s[0]-'a';
pot[1] = 37;
int p = 1;
for (int i = 2; i <= n; i++){
H[i] = 37*H[i-1] + s[i-1]-'a';
pot[i] = pot[i-1] * 37;
}
int sol = 1;
int d = 1, o = 0;
for (int i = 0; i < n/2; i++){
long long hl = h(o, o + d-1);
long long hd = h(n-o-d, n-o-1);
/*
cout << d << " " << o << "\n";
cout << sol << "\n";
cout << hl << " " << hd << "\n";
*/
if (hl == hd){
o += d;
d = 0;
sol+= 2;
}
d++;
}
if (n%2 == 0 && d == 1)sol--;
cout << sol << "\n";
}
return 0;
}
컴파일 시 표준 에러 (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... | ||||
