結果

問題 No.291 黒い文字列
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2015-10-16 23:58:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,709 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 89,924 KB
実行使用メモリ 43,932 KB
最終ジャッジ日時 2023-09-29 12:23:12
合計ジャッジ時間 20,076 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
43,720 KB
testcase_01 AC 85 ms
43,600 KB
testcase_02 WA -
testcase_03 AC 158 ms
43,724 KB
testcase_04 AC 86 ms
43,664 KB
testcase_05 AC 89 ms
43,616 KB
testcase_06 AC 64 ms
43,652 KB
testcase_07 AC 95 ms
43,716 KB
testcase_08 AC 104 ms
43,592 KB
testcase_09 AC 64 ms
43,596 KB
testcase_10 AC 509 ms
43,800 KB
testcase_11 AC 311 ms
43,608 KB
testcase_12 AC 313 ms
43,656 KB
testcase_13 AC 85 ms
43,660 KB
testcase_14 AC 218 ms
43,648 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 990 ms
43,660 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1,392 ms
43,668 KB
testcase_26 AC 1,397 ms
43,660 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];
                    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'){
                    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