結果

問題 No.38 赤青白ブロック
ユーザー tnakao0123tnakao0123
提出日時 2016-03-03 20:02:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 169 ms / 5,000 ms
コード長 1,513 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 84,304 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 01:13:44
合計ジャッジ時間 5,642 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
4,376 KB
testcase_01 AC 124 ms
4,376 KB
testcase_02 AC 128 ms
4,380 KB
testcase_03 AC 132 ms
4,376 KB
testcase_04 AC 123 ms
4,380 KB
testcase_05 AC 167 ms
4,376 KB
testcase_06 AC 129 ms
4,376 KB
testcase_07 AC 124 ms
4,376 KB
testcase_08 AC 169 ms
4,376 KB
testcase_09 AC 136 ms
4,380 KB
testcase_10 AC 159 ms
4,376 KB
testcase_11 AC 167 ms
4,380 KB
testcase_12 AC 131 ms
4,380 KB
testcase_13 AC 165 ms
4,376 KB
testcase_14 AC 136 ms
4,380 KB
testcase_15 AC 168 ms
4,380 KB
testcase_16 AC 104 ms
4,380 KB
testcase_17 AC 123 ms
4,376 KB
testcase_18 AC 161 ms
4,380 KB
testcase_19 AC 145 ms
4,376 KB
testcase_20 AC 128 ms
4,380 KB
testcase_21 AC 120 ms
4,376 KB
testcase_22 AC 139 ms
4,376 KB
testcase_23 AC 149 ms
4,380 KB
testcase_24 AC 122 ms
4,380 KB
testcase_25 AC 143 ms
4,376 KB
testcase_26 AC 140 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 38.cc: No.38 赤青白ブロック - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 10;
const int SN = N * 3;
const int BITS = 1 << (N * 2);

const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int cps[SN], ts[SN];

/* subroutines */

/* main */

int main() {
  int kr, kb;
  string s;
  cin >> kr >> kb >> s;

  int ri = 0, bi = N;
  for (int i = 0; i < SN; i++)
    switch (s[i]) {
    case 'R': cps[i] = ri++; break;
    case 'B': cps[i] = bi++; break;
    case 'W': cps[i] = -1; break;
    }

  int maxl = 0;
  for (int bits = 0; bits < BITS; bits++) {
    int tn = 0;
    for (int i = 0; i < SN; i++) {
      if (cps[i] < 0) ts[tn++] = -1;
      else if (bits & (1 << cps[i])) {
	if (cps[i] < N) ts[tn++] = 0;
	else ts[tn++] = 1;
      }
    }

    bool ok = true;
    for (int i = 0; ok && i < tn; i++)
      switch (ts[i]) {
      case 0: 
	if (i + kr < tn && ts[i + kr] == 0) ok = false;
	break;
      case 1: 
	if (i + kb < tn && ts[i + kb] == 1) ok = false;
	break;
      }

    if (ok && maxl < tn) maxl = tn;
  }

  printf("%d\n", maxl);
  return 0;
}
0