| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 853324 | manizare | Palindromic Partitions (CEOI17_palindromic) | C++14 | 1 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define Pii pair< pii , pii >
#define ll long long
using namespace std ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 10002 + 10 , maxq = 1e7 + 1 , inf = 1e8 + 10 , mod= 998244353 ,lg = 20 ;
int lcp[maxn] ,dp[maxn] ;
signed main(){
ios::sync_with_stdio(false); cin.tie(0) ;
int t;
cin >> t ;
while(t--){
string s ;
cin >> s ;
int n = (int)s.size() ;
s = " " + s;
if(n%2==1)dp[n/2+1] = 1 ;
for(int i = n/2 ; i >= 1 ; i--){
int k =0 ;
dp[i] = 1;
string a , b;
for(int j = i ; j <= n/2 ; j++){
a += s[j] ;
}
for(int j = n+1 - n/2; j<= n-i+1 ; j++){
b += s[j] ;
}
lcp[0] = 0 ;
for(int j = 1 ; j < a.size() ; j++){
while(k!=0 && a[k] != a[j]){
k = lcp[k-1] ;
}
if(a[k] == a[j])k++;
lcp[j]= k ;
}
k =0 ;
int f ;
for(int j = 0 ; j < b.size() ; j++){
while(k!=0 && b[j] != a[k]){
k = lcp[k-1] ;
}
if(b[j] == a[k])k++;
f = k ;
}
while(f!=0){
dp[i] = max(dp[i] , dp[i+f] + 2) ;
f = lcp[f-1];
}
}
cout << dp[1] << "\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... | ||||
