# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
858999 | VinhLuu | Palindromic Partitions (CEOI17_palindromic) | C++17 | 584 ms | 131072 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
//#define int long long
using namespace std;
const ll mod = 1e9 + 7;
const int Max = 1e6 + 5;
const ll dm = 998244353;
string s[Max];
int dp[Max],n;
ll lt[Max],hs[Max],t[Max],pw[Max];
int get(int i,int j){
return (hs[j]%mod + mod - (1LL * hs[i - 1]*lt[j - i + 1])%mod)%mod;
}
int got(int i,int j){
return (t[j]%dm + dm - (1LL * t[i - 1]*pw[j - i + 1])%dm)%dm;
}
int dfs(int i){
if(dp[i] != 0) return dp[i];
dp[i] = 1;
int l = i, r = n - i + 1;
if(l > r) return dp[i] = 0;
if(l == r) return dp[i] = 1;
int mid = (r - l + 1) / 2;
for(int j = 1; j <= mid; j ++){
if(get(l, l + j - 1) == get(r - j + 1, r) && got(l, l + j - 1) == got(r - j + 1, r)){
# | 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... |