# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1097143 | 2024-10-06T09:18:07 Z | vjudge1 | Palindromic Partitions (CEOI17_palindromic) | C++17 | 134 ms | 28768 KB |
#include<bits/stdc++.h> #define ll long long using namespace std; const int mod=998244353,moi=1e6+111,base=311,mod1=1e9+7,base1=331; string s,t; int n; bool check; ll Pow[moi],Hash[moi],Pow1[moi],Hash1[moi]; ll gethash(int i,int j) { return (Hash[j]-Hash[i-1]*Pow[j-i+1]%mod+mod)%mod; } void Input() { int x; cin>>x; while(x--) { int res=0; cin>>s; n=s.size(); s=" "+s; Pow[0]=1; Hash[0]=0; for(int i=1;i<=n;i++) { Pow[i]=Pow[i-1]*base%mod; Hash[i]=(Hash[i-1]*base%mod+s[i]-'a')%mod; } int l=1,r=n; for(int i=1,j=n;i<j;i++,j--) { ll hash1=gethash(l,i); ll hash2=gethash(j,r); if(hash1==hash2) { res+=2; l=i+1; r=j-1; } } if(l<=r)res++; cout<<res<<'\n'; } } 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 2 ms | 604 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 | 608 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 2 ms | 604 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 | 608 KB | Output is correct |
14 | Correct | 134 ms | 27684 KB | Output is correct |
15 | Correct | 74 ms | 22808 KB | Output is correct |
16 | Correct | 127 ms | 28768 KB | Output is correct |
17 | Correct | 71 ms | 14804 KB | Output is correct |