結果

問題 No.291 黒い文字列
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2015-10-16 23:29:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,750 bytes
コンパイル時間 771 ms
コンパイル使用メモリ 87,328 KB
実行使用メモリ 43,936 KB
最終ジャッジ日時 2023-09-29 01:56:21
合計ジャッジ時間 26,065 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
43,676 KB
testcase_01 AC 85 ms
43,668 KB
testcase_02 AC 247 ms
43,660 KB
testcase_03 AC 160 ms
43,660 KB
testcase_04 AC 85 ms
43,592 KB
testcase_05 AC 174 ms
43,616 KB
testcase_06 AC 230 ms
43,588 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 66 ms
43,624 KB
testcase_10 WA -
testcase_11 AC 369 ms
43,724 KB
testcase_12 AC 366 ms
43,592 KB
testcase_13 AC 86 ms
43,656 KB
testcase_14 AC 233 ms
43,664 KB
testcase_15 AC 165 ms
43,596 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1,547 ms
43,684 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1,501 ms
43,728 KB
testcase_26 AC 1,504 ms
43,724 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))

#define MOD 1000000007

int dp[2][22][22][22][22][22];

int main() {
    clr(dp,0);
    string s;
    cin>>s;
    if(s[0]=='K'||s[0]=='?'){
      dp[0][1][0][0][0][0] = 1;
    }
    else{
      dp[0][0][0][0][0][0] = 1;
    }
    int old = 0;
    int now = 1;
    rep(j,1,s.sz){
        rep(k,0,21){
          rep(u,0,21){
            rep(r,0,21){
              rep(o,0,21){
                rep(i,0,21){
                  if(s[j]=='?'){
                    dp[now][k+1][u][r][o][i] += dp[old][k][u][r][o][i];
                    if(k>u)dp[now][k][u+1][r][o][i] += dp[old][k][u][r][o][i];
                    if(u>r)dp[now][k][u][r+1][o][i] += dp[old][k][u][r][o][i];
                    if(r>o)dp[now][k][u][r][o+1][i] += dp[old][k][u][r][o][i];
                    if(o>i)dp[now][k][u][r][o][i+1] += dp[old][k][u][r][o][i];
                  }
                  else if(s[j]=='K'){
                    dp[now][k+1][u][r][o][i] += dp[old][k][u][r][o][i];
                  }
                  else if(s[j]=='U'){
                    if(k>u)dp[now][k][u+1][r][o][i] += dp[old][k][u][r][o][i];
                  }
                  else if(s[j]=='R'){
                    if(u>r)dp[now][k][u][r+1][o][i] += dp[old][k][u][r][o][i];
                  }
                  else if(s[j]=='O'){
                    if(r>o)dp[now][k][u][r][o+1][i] += dp[old][k][u][r][o][i];
                  }
                  else if(s[j]=='I'){
                    if(o>i)dp[now][k][u][r][o][i+1] += dp[old][k][u][r][o][i];
                  }
                  else{
                    dp[now][k][u][r][o][i] += dp[old][k][u][r][o][i];
                  }
                }
              }
            }
          }
        }
        clr(dp[old],0);
        old = 1-old;
        now = 1-now;
    }
    int mx = 0;
    rep(k,0,21){
          rep(u,0,21){
            rep(r,0,21){
              rep(o,0,21){
                rep(i,0,21){
                  if(dp[old][k][u][r][o][i] > 0){
                    mx = max(mx,min(k,min(u,min(r,min(o,i)))));
                  }
                }
              }
            }
          }
    }
    cout << mx << endl;
    return 0;
}
0