# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
44885 | TAMREF | Savez (COCI15_savez) | C++11 | 176 ms | 36516 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<ll,ll> pll;
const int mx = 2e6 + 5;
const ll mod[2] = {1000000007LL,1610612741LL};
map<ll,int> M;
char S[mx];
unsigned int pfx[2][mx], sfx[2][mx];
unsigned int pow_27[2][mx] = {{1u},{1u}};
int n;
void init(){
scanf("%d",&n);
for(int b=0;b<2;b++)
for(int i=1;i<mx;i++)
pow_27[b][i] = 27LL * pow_27[b][i-1] % mod[b];
}
void update(){
scanf("%*c%s",S+1);
int l = strlen(S+1);
for(int b = 0; b < 2 ; b++)
for(int i = 1; i <= l; i++){
pfx[b][i] = (27LL * pfx[b][i-1] + (S[i] - 'A' + 1)) % mod[b];
}
sfx[0][l+1] = sfx[1][l+1] = 0;
for(int b = 0; b < 2; b++)
for(int i = l; i >= 1; i--){
sfx[b][i] = ((ll)pow_27[b][l-i] * (S[i] - 'A' + 1) + sfx[b][i+1]) % mod[b];
}
int dlen = 1;
for(int i = 1; i <= l; i++){
if(pfx[0][i] == sfx[0][l+1-i] && pfx[1][i] == sfx[1][l+1-i]){
dlen = max(dlen, M[(ll)pfx[0][i] << 32 | pfx[1][i]] + 1);
}
}
M[(ll)pfx[0][l] << 32 | pfx[1][l]] = dlen;
}
void output(){
int ans = 1;
for(auto p : M){
ans = max(ans, p.second);
}
printf("%d\n",ans);
}
int main(){
init();
for(int i=1;i<=n;i++){
update();
}
output();
}
컴파일 시 표준 에러 (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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |