# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1017419 | cnn008 | Palindromic Partitions (CEOI17_palindromic) | C++17 | 104 ms | 28776 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#ifdef N_N_C
#include "debug.h"
#else
#define cebug(...) "Arya"
#endif
#define int long long
const int N=1e6+5;
const int mod=1e9+7;
const int base=311;
int n,ans,h[N],pw[N];
string s;
int get(int l, int r){
return (h[r]-((h[l-1]*pw[r-l+1])%mod)+mod)%mod;
}
void sol(){
ans=0;
cin>>s;
n=(int)s.size();
s=' '+s;
for(int i=1; i<=n; i++) h[i]=(h[i-1]*base+s[i]-'a'+1)%mod;
int l=1,r=n;
while(l<=r){
int _l=l,_r=r,f=0;
while(_l<_r){
if(get(l,_l++)==get(_r--,r)){
cebug(s,l,_l,_r,r);
ans+=2;
f=1;
break;
}
}
if(!f){
ans++;
break;
}
l=_l;
r=_r;
}
cout<<ans<<"\n";
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen(".inp", "r", stdin);
// freopen(".out", "w", stdout);
pw[0]=1;
for(int i=1; i<N; i++) pw[i]=(pw[i-1]*base)%mod;
int tt=1;
cin>>tt;
while(tt--){
sol();
}
cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
return 0;
}
컴파일 시 표준 에러 (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... |