# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
939169 | 2024-03-06T06:25:41 Z | vjudge1 | Palindromic Partitions (CEOI17_palindromic) | C++17 | 6 ms | 8028 KB |
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; const int N=1e6+5,mod=1e9+7,tt=13; int pw[N]; signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int t; cin>>t; pw[0]=1; for(int i=1;i<N;i++){ pw[i]=pw[i-1]*tt; pw[i]%=mod; } while(t--){ string s; cin>>s; s=" "+s; vector <int> h(s.size()); for(int i=1;i<s.size();i++){ h[i]=h[i-1]*tt+(s[i]-'a'+1); h[i]%=mod; } int st1=1,end2=s.size()-1; int end1=1,st2=s.size()-1; int h1=0,h2=0; int ans=0; while(end1<st2){ h1=(h[end1]-h[st1-1]*pw[end1-st1+1])%mod; h2=(h[end2]-h[st2-1]*pw[end2-st2+1])%mod; if(h1==h2){ end1++; st1=end1; st2--; end2=st2; ans+=2; } else{ st2--; end1++; } } if(st1<=end2)ans++; cout<<ans<<"\n"; } } /* */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 8028 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 8028 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 8028 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 8028 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |