結果
問題 |
No.464 PPAP
|
ユーザー |
![]() |
提出日時 | 2025-07-27 20:04:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 149 ms / 2,000 ms |
コード長 | 2,068 bytes |
コンパイル時間 | 1,698 ms |
コンパイル使用メモリ | 198,648 KB |
実行使用メモリ | 28,344 KB |
最終ジャッジ日時 | 2025-07-27 20:04:27 |
合計ジャッジ時間 | 2,988 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include<bits/stdc++.h> #define int long long #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() bool st; using namespace std; template<typename T>istream&operator>>(istream&I,vector<T>&v){for(auto&i:v)I>>i;return I;} template<typename T>ostream&operator<<(ostream&O,vector<T> v){for(auto i:v)O<<i<<' ';return O;} string TMP,STR; stringstream CIN; void read_all(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #ifdef debug cerr<<"----------------------------------- START -----------------------------------\n"; while(getline(cin,TMP))STR+=TMP,STR+='\n'; CIN.str(STR); cerr<<"\n--------------------------------- INPUT END ---------------------------------\n"; #endif } #ifdef debug #define cin CIN #endif namespace AC{ bool p[5010][5010]; int dp[5010][5]; void solve(){ string S; cin>>S; int n=S.size(); for(int sl=0;sl<n;sl++)for(int sr=sl;sr<min(n,sl+2);sr++)for(int l=sl,r=sr;l>=0&&r<n;--l,++r){ if(S[l]!=S[r])break; p[l][r+1]=1; } dp[0][0]=1; for(int i=0;i<n;i++)for(int j=0;j<4;j++)for(int k=i+1;k<=n;k++)if(j==2||p[i][k])dp[k][j+1]+=dp[i][j]; cout<<dp[n][4]<<endl; } } bool ed; signed main(){ chrono::steady_clock::time_point St=chrono::steady_clock::now(); read_all(); chrono::steady_clock::time_point ST=chrono::steady_clock::now(); int t=1; //cin>>t; while(t--)AC::solve(); chrono::steady_clock::time_point ED=chrono::steady_clock::now(); cerr<<setprecision(3)<<fixed<<"\n\n------------------------------------ END ------------------------------------\n"<<"Total Time : "<<left<<setw(10)<<chrono::duration_cast<chrono::milliseconds>(ED-St).count()<<" \tms\n"<<"Real Time : "<<left<<setw(10)<<chrono::duration_cast<chrono::milliseconds>(ED-ST).count()<<" \tms\n"<<" : "<<left<<setw(10)<<chrono::duration_cast<chrono::microseconds>(ED-ST).count()<<" \t?s\n\n"<<"Total Memory : "<<left<<setw(10)<<(&ed-&st)/1048576.0<<" \tMB\n"<<" "<<left<<setw(10)<<(&ed-&st)/1024.0<<" \tKB\n"<<" "<<left<<setw(10)<<(&ed-&st)<<" \tByte\n"; }