結果
| 問題 |
No.1542 ぽんぽんぽん ぽんぽんぽんぽん ぽんぽんぽん
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2021-06-06 19:48:45 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,199 bytes |
| コンパイル時間 | 3,138 ms |
| コンパイル使用メモリ | 182,332 KB |
| 最終ジャッジ日時 | 2025-01-22 04:23:19 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 28 |
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
int main()
{
int n;
string s; cin>>n>>s;
int dp[7][505];
for(int i=0; i<=6; i++) fill(dp[i], dp[i]+n+1, -1);
string s0="ponpon";
dp[0][0]=0;
for(int i=0; i<=6; i++){
for(int j=0; j<n; j++){
if(dp[i][j]==-1) continue;
dp[i][j+1]=max(dp[i][j+1], dp[i][j]);
if(j+3<n && s.substr(j, 3)=="pon"){
dp[i][j+3]=max(dp[i][j+3], dp[i][j]+1);
}
if(i<6 && s[j]==s0[i]){
dp[i+1][j+1]=max(dp[i+1][j+1], dp[i][j]);
}
}
}
cout<<dp[6][n]<<endl;
return 0;
}
chocorusk