結果
問題 | No.38 赤青白ブロック |
ユーザー | yuki2006 |
提出日時 | 2014-10-12 23:33:13 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,919 bytes |
コンパイル時間 | 4,606 ms |
コンパイル使用メモリ | 74,880 KB |
実行使用メモリ | 62,576 KB |
最終ジャッジ日時 | 2023-08-28 20:55:14 |
合計ジャッジ時間 | 23,691 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 693 ms
61,140 KB |
testcase_01 | AC | 539 ms
60,544 KB |
testcase_02 | AC | 555 ms
60,468 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 902 ms
60,524 KB |
testcase_09 | WA | - |
testcase_10 | AC | 734 ms
60,732 KB |
testcase_11 | AC | 853 ms
60,684 KB |
testcase_12 | AC | 536 ms
60,796 KB |
testcase_13 | AC | 755 ms
61,200 KB |
testcase_14 | AC | 531 ms
60,676 KB |
testcase_15 | AC | 754 ms
60,908 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 776 ms
60,288 KB |
testcase_19 | AC | 602 ms
60,776 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 787 ms
60,212 KB |
testcase_24 | WA | - |
testcase_25 | AC | 586 ms
60,840 KB |
testcase_26 | WA | - |
ソースコード
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; } } StringBuilder t = new StringBuilder(); for (int i = mask; i < (1 << N); i = (i + 1) | mask) { t.delete(0, t.length()); for (int j = 0; j < N; j++) { if (s.charAt(j) == 'W' || (((1 << j) & i) > 0)) { t.append(s.charAt(j)); } } boolean hit = false; LOOP: 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]) { if (t.charAt(j - c[1]) == c[0]) { hit = true; break LOOP; } } if (j + c[1] < t.length()) { if (t.charAt(j + c[1]) == c[0]) { hit = true; break LOOP; } } } } } if (!hit) { ans = Math.max(ans, t.length()); } } System.out.println(ans); } }