結果

問題 No.291 黒い文字列
ユーザー r_dream0r_dream0
提出日時 2017-03-01 21:44:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,133 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 65,084 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-03 17:08:48
合計ジャッジ時間 5,978 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,388 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 4 ms
4,384 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 497 ms
4,384 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 WA -
testcase_23 AC 1,806 ms
4,380 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 1 ms
4,384 KB
testcase_29 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
const long T1 = 101;
const long T2 = 101L * 101;
const long T3 = 101L * 101 * 101;
const long T4 = 101L * 101 * 101 * 101;
string s;

long next(long KUROI, char c) {
  int k = KUROI % 101;
  int u = KUROI / T1 % 101;
  int r = KUROI / T2 % 101;
  int o = KUROI / T3 % 101;
  int i = KUROI / T4 % 101;
  if(c == 'K') {
    k++;
  } else if(c == 'U') {
    u = min(u + 1, k);
  } else if(c == 'R') {
    r = min(r + 1, u);
  } else if(c == 'O') {
    o = min(o + 1, r);
  } else if(c == 'I') {
    i = min(i + 1, o);
  }
  return k + u * T1 + r * T2 + o * T3 + i * T4;
}
long solve(int k, long KUROI, int cur) {
  long answer = 0;
  if(k == s.size()) {
    return KUROI / T4 % 101;
  }
  switch(s[k]) {
    case 'K':
    case 'U':
    case 'R':
    case 'O':
    case 'I':
      return solve(k + 1, next(KUROI, s[k]), cur);
    case '?':
      for(int j = cur; j < 5; j++) {
        answer = max(answer, solve(k + 1, next(KUROI, "KUROI"[j]), j));
      }
      return answer;
    default:
      return solve(k + 1, KUROI, cur);
  }
}
int main() {
  cin >> s;
  cout << solve(0, 0, 0) << endl;
}
0