Submission #1095047

# Submission time Handle Problem Language Result Execution time Memory
1095047 2024-10-01T07:55:45 Z vjudge1 Palindromic Partitions (CEOI17_palindromic) C++17
100 / 100
94 ms 23352 KB
#include<bits/stdc++.h>
using namespace std;
long long n,m,base=311,k,t,mod=1e9+7,has[1000005],p[1000005];
long long get(long long x,long long y)
{
  return (has[y]-has[x-1]*p[y-x+1]+mod*mod)%mod;
}
string s;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin>>t;
  while(t--)
  {
  long long ans=0;
  cin>>s;
  n=s.length();
  s=' '+s;
  p[0]=1;
  for(int i=1;i<=n;i++)
   {
     p[i]=(p[i-1]*base)%mod;
     has[i]=(has[i-1]*base+s[i]-'a'+1)%mod;
   }
  long long neil=1,nei=n;
  for(int i=1;i<=n/2;i++)
  {
    if(get(neil,i)==get(nei-(i-neil),nei)) ans+=2,neil=i+1,nei=n-i;
  }
  if(neil<=nei) ans++;
  cout<<ans<<'\n';
  }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 94 ms 23352 KB Output is correct
15 Correct 53 ms 17936 KB Output is correct
16 Correct 85 ms 19524 KB Output is correct
17 Correct 47 ms 9716 KB Output is correct