# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1096976 | 2024-10-05T15:31:48 Z | moiaaaaaaa | Palindromic Partitions (CEOI17_palindromic) | C++14 | 0 ms | 348 KB |
#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(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |