# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1096976 | moiaaaaaaa | Palindromic Partitions (CEOI17_palindromic) | C++14 | 0 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7,moi=1e6+111,base=311,mod1=1e9+7,base1=331;
string s,t;
int n,m;
bool check;
ll Pow[moi],Hash[moi],kmp[moi];
ll gethash(int i,int j)
{
return (Hash[j]-Hash[i-1]*Pow[j-i+1]%mod+mod)%mod;
}
void Input()
{
cin>>m;
while(m--)
{
cin>>s;
int res=0;
while(1)
{
n=s.size();
s=" "+s;
int k=kmp[1]=0;
for(int i=2;i<=n;i++)
{
while(k>0&&s[i]!=s[k+1]){k=kmp[k];}
if(s[i]==s[k+1])kmp[i]=++k;
else kmp[i]=0;
}
k=kmp[n];
if(k==0){res++;cout<<res<<'\n';break;}
while(kmp[k]>0){k=kmp[k];}
s.erase(n-k+1,k);
s.erase(0,k+1);
res+=2;
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
if(fopen("a.inp","r"))
{
freopen("a.inp","r",stdin);
freopen("a.out","w",stdout);
}
Input();
}
컴파일 시 표준 에러 (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... |