結果

問題 No.38 赤青白ブロック
ユーザー yuki2006yuki2006
提出日時 2014-10-12 22:58:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,674 bytes
コンパイル時間 3,988 ms
コンパイル使用メモリ 76,268 KB
実行使用メモリ 63,388 KB
最終ジャッジ日時 2023-08-28 20:52:57
合計ジャッジ時間 34,364 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,065 ms
60,896 KB
testcase_01 AC 985 ms
61,248 KB
testcase_02 AC 829 ms
60,696 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1,176 ms
61,044 KB
testcase_09 WA -
testcase_10 AC 1,103 ms
60,396 KB
testcase_11 AC 1,135 ms
60,820 KB
testcase_12 AC 882 ms
60,576 KB
testcase_13 AC 1,158 ms
61,380 KB
testcase_14 AC 874 ms
60,692 KB
testcase_15 AC 1,246 ms
61,008 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1,142 ms
61,164 KB
testcase_19 AC 942 ms
61,176 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1,092 ms
60,904 KB
testcase_24 WA -
testcase_25 AC 920 ms
60,380 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yuki038 {
    public static void main(String[] args) {
        Yuki038 hoge = new Yuki038();
    }

    Yuki038() {
        Scanner scanner = new Scanner(System.in);
        int kr = scanner.nextInt();
        int kb = scanner.nextInt();
        String s = scanner.next();
        int ans = 0;
        int N = s.length();
        int mask = 0;
        for (int i = 0; i < N; i++) {
            if (s.charAt(i) == 'W') {
                mask |= 1 << i;
            }
        }

        for (int i = mask; i < (1 << N); i = (i + 1) | mask) {
            String t = "";
            for (int j = 0; j < N; j++) {
                if (s.charAt(j) == 'W' || (((1 << j) & i) > 0)) {
                    t += s.charAt(j);
                }
            }
            boolean hit = false;

            for (int j = 0; j < t.length(); j++) {
                if (t.charAt(j) == 'W') {
                    continue;
                }

                for (int[] c : new int[][]{{'R', kr}, {'B', kb}}) {
                    if (s.charAt(j) == c[0]) {
                        if (j >= c[1]) {
                            hit |= t.charAt(j - c[1]) == c[0];
                        }
                        if (j + c[1] < t.length()) {
                            hit |= t.charAt(j + c[1]) == c[0];
                        }
                    }
                }
                if (hit) {
                    break;
                }
            }
            if (!hit) {
                ans = Math.max(ans, t.length());
            }

        }
        System.out.println(ans);

    }

}
0