結果
| 問題 |
No.291 黒い文字列
|
| ユーザー |
|
| 提出日時 | 2020-08-31 04:31:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 63 ms / 2,000 ms |
| コード長 | 1,240 bytes |
| コンパイル時間 | 726 ms |
| コンパイル使用メモリ | 69,248 KB |
| 最終ジャッジ日時 | 2025-01-14 02:16:15 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
6 | main() {
| ^~~~
ソースコード
#include <iostream>
using namespace std;
#define chmax(p,q) (p<q?p=q:p)
int dp[101][22][22][22][22];
main() {
string s;
cin>>s;
int ans=1;
dp[0][0][0][0][0]=1;
for (int i=0;i<s.size();++i) {
for (int K=0;K<=20;++K) {
for (int U=0;U<=K;++U) {
for (int R=0;R<=U;++R) {
for (int O=0;O<=R;++O) {
int t=dp[i][K][U][R][O];
if (t!=0) {
char c=s[i];
if (c=='K' || c=='?') chmax(dp[i+1][K+1][U][R][O],t);
if (c=='U' || c=='?') chmax(dp[i+1][K][U+1][R][O],t);
if (c=='R' || c=='?') chmax(dp[i+1][K][U][R+1][O],t);
if (c=='O' || c=='?') chmax(dp[i+1][K][U][R][O+1],t);
if (c=='I' || c=='?') if (O>t-1) {
chmax(dp[i+1][K][U][R][O],t+1);
ans=max(ans,dp[i+1][K][U][R][O]);
}
chmax(dp[i+1][K][U][R][O],dp[i][K][U][R][O]);
}
}
}
}
}
}
cout<<ans-1<<endl;
}