# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
493434 | JovanB | 회문 (APIO14_palindrome) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define PRINT(x) cerr<<#x<<'='<<x<<endl;
using namespace std;
struct PalTree {
#define P_SIGMA 26
#define FIRST_NODE 1
#define SECOND_NODE 2
struct Node {
int len, cnt, dub, slink;
int to[P_SIGMA];
Node() { len = cnt = dub = slink = 0; for(int i = 0; i < P_SIGMA; i++) to[i] = 0; }
Node(int _len, int _cnt, int _dub, int _slink) {
len = _len; cnt = _cnt; dub = _dub; slink = _slink;
for(int i = 0; i < P_SIGMA; i++) to[i] = 0;
}
};
string s;
vector<Node> pt;
int suff;
int toidx(char c) { return c-'a'; }
void addLetter(char c) {
s += c; int len = s.size();
assert(0 <= len-2-pt[suff.len]);
while(c != s[len-2-pt[suff].len]) {
suff = pt[suff].slink;
}
int nd = pt[suff].to[toidx(c)];
if(nd == 0) {
nd = pt.size();