| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 858406 | Tenis0206 | Palindromic Partitions (CEOI17_palindromic) | C++11 | 117 ms | 20864 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e6;
const int b = 27;
const int Mod = 1e9 + 7;
string s;
int h[nmax + 5];
int put[nmax + 5];
int get_hash(int st, int dr)
{
return (h[dr] - 1LL * h[st - 1] * put[dr - st + 1] % Mod + Mod) % Mod;
}
int solve(int st, int dr)
{
if(st > dr)
{
return 0;
}
for(int len=1;st + len - 1 < dr - len + 1;len++)
{
bool ok = (get_hash(st,st+len-1) == get_hash(dr-len+1,dr));
if(ok)
{
return 2 + solve(st + len, dr - len);
}
}
return 1;
}
void solve_test()
{
cin>>s;
s = "#" + s;
put[0] = 1;
for(int i=1;i<s.size();i++)
{
put[i] = 1LL * put[i - 1] * b % Mod;
h[i] = (1LL * h[i - 1] * b + s[i] - 'a' + 1) % Mod;
}
cout<<solve(1,s.size() - 1)<<'\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
#ifdef home
freopen("nr.in","r",stdin);
freopen("nr.out","w",stdout);
#endif // home
int t;
cin>>t;
for(int test=1;test<=t;test++)
{
solve_test();
}
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... | ||||
