結果
問題 | No.599 回文かい |
ユーザー |
|
提出日時 | 2024-10-17 21:41:08 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,900 bytes |
コンパイル時間 | 2,796 ms |
コンパイル使用メモリ | 246,380 KB |
実行使用メモリ | 784,000 KB |
最終ジャッジ日時 | 2024-10-17 21:41:17 |
合計ジャッジ時間 | 7,940 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 MLE * 9 |
ソースコード
#include <bits/stdc++.h>#include <cmath>//#include <ranges>using ll=long long;using lu=unsigned long long;#define rep(i,a,b) for(int i=a;i<b;i++)#define chmin(x,b) x=min(x,b)using namespace std;#define fi first#define se secondusing P=pair<int,int>;using PD=pair<double,double>;using PL=pair<ll,ll>;using PH=pair<int,char>;using PS=pair<string,ll>;int mod1=998244353;int mod2=1000000007;const ll INF = 5000000000000000000;const int big = 2147483647;ll N=1;/*struct st{ll x,y,z;st(ll x=0,ll y=0,ll z=0):x(x),y(y),z(z){}bool operator>(const st &a) const {if (x != a.x) return x > a.x;if (y != a.y) return y > a.y;return z > a.z;}};*/ll A[10001][10001];vector<ll>rec(5010,INF);//mt19937_64 rng(1644);const ll mod=(1ll<<61)-1;int main(){//16:30//ll n=0,q,y=0,i=0,z=0,x=0,d=0,k=0,nk,sum=0;//ll ans=INF,sum2=0,rs=-INF,cs=0,l=0,h=0,r=0;//ll a=0,b=0,c=0,j=0,m=0,K=0;ll M=0,R,w,L;string s;cin>>s;N=s.size();rep(i,0,N){ll res=0;rep(j,i,N){(res*=1234567)%=mod;(res+=(s[j]-'a'))%=mod;A[i][j]=res;}}bool jud=false;auto f=[&](auto f,int l,int r)->ll{//cout<<l<<r<<endl;//if(jud)return 0;if(r<=l){//jud=true;return 1;}if(rec[l]!=INF){//cout<<"/////////////////////"<<endl;return rec[l];}int L=l;int R=r;ll res=1;while(l<r){if(A[L][l]==A[r][R]){//cout<<l<<" "<<r<<endl;//cout<<A[L][l]<<" "<<A[r][R]<<endl;(res+=f(f,l+1,r-1))%=mod2;}l++;r--;}//cout<<"*************************"<<rec[144]<<endl;rec[L]=res;return res;};cout<<f(f,0,N-1)<<endl;}