結果

問題 No.291 黒い文字列
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2015-10-17 00:05:04
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,710 bytes
コンパイル時間 1,374 ms
コンパイル使用メモリ 90,996 KB
実行使用メモリ 43,932 KB
最終ジャッジ日時 2023-09-29 12:26:25
合計ジャッジ時間 29,676 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
43,504 KB
testcase_01 AC 88 ms
43,808 KB
testcase_02 AC 202 ms
43,568 KB
testcase_03 AC 160 ms
43,508 KB
testcase_04 AC 89 ms
43,564 KB
testcase_05 AC 88 ms
43,508 KB
testcase_06 AC 66 ms
43,648 KB
testcase_07 AC 116 ms
43,504 KB
testcase_08 AC 190 ms
43,568 KB
testcase_09 AC 131 ms
43,656 KB
testcase_10 AC 525 ms
43,800 KB
testcase_11 AC 697 ms
43,504 KB
testcase_12 AC 614 ms
43,628 KB
testcase_13 AC 89 ms
43,684 KB
testcase_14 AC 231 ms
43,656 KB
testcase_15 AC 178 ms
43,564 KB
testcase_16 WA -
testcase_17 AC 1,647 ms
43,600 KB
testcase_18 AC 1,510 ms
43,640 KB
testcase_19 TLE -
testcase_20 TLE -
testcase_21 WA -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 AC 1,433 ms
43,660 KB
testcase_26 AC 1,432 ms
43,604 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;
    string s1;
    rep(i,0,s.sz){
      if(s[i]=='K'||s[i]=='U'||s[i]=='R'||s[i]=='O'||s[i]=='I'||s[i]=='?'){
        s1 += s[i];
      }
    }
    s = "I"+s1;
    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];
                    dp[now][k][min(k,u+1)][r][o][i] += dp[old][k][u][r][o][i];
                    dp[now][k][u][min(u,r+1)][o][i] += dp[old][k][u][r][o][i];
                    dp[now][k][u][r][min(r,o+1)][i] += dp[old][k][u][r][o][i];
                    dp[now][k][u][r][o][min(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'){
                    dp[now][k][min(k,u+1)][r][o][i] += dp[old][k][u][r][o][i];
                  }
                  else if(s[j]=='R'){
                    dp[now][k][u][min(u,r+1)][o][i] += dp[old][k][u][r][o][i];
                  }
                  else if(s[j]=='O'){
                    dp[now][k][u][r][min(r,o+1)][i] += dp[old][k][u][r][o][i];
                  }
                  else if(s[j]=='I'){
                    dp[now][k][u][r][o][min(o,i+1)] += 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