結果
問題 | No.38 赤青白ブロック |
ユーザー | yuki2006 |
提出日時 | 2014-10-12 23:44:38 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 814 ms / 5,000 ms |
コード長 | 1,994 bytes |
コンパイル時間 | 3,757 ms |
コンパイル使用メモリ | 74,916 KB |
実行使用メモリ | 61,020 KB |
最終ジャッジ日時 | 2023-08-25 00:52:42 |
合計ジャッジ時間 | 23,044 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 681 ms
60,276 KB |
testcase_01 | AC | 694 ms
60,376 KB |
testcase_02 | AC | 601 ms
59,360 KB |
testcase_03 | AC | 695 ms
60,084 KB |
testcase_04 | AC | 665 ms
60,100 KB |
testcase_05 | AC | 713 ms
60,536 KB |
testcase_06 | AC | 584 ms
60,152 KB |
testcase_07 | AC | 556 ms
60,400 KB |
testcase_08 | AC | 639 ms
60,796 KB |
testcase_09 | AC | 589 ms
60,248 KB |
testcase_10 | AC | 736 ms
58,656 KB |
testcase_11 | AC | 778 ms
60,740 KB |
testcase_12 | AC | 605 ms
60,096 KB |
testcase_13 | AC | 814 ms
60,888 KB |
testcase_14 | AC | 627 ms
60,296 KB |
testcase_15 | AC | 664 ms
60,496 KB |
testcase_16 | AC | 538 ms
60,136 KB |
testcase_17 | AC | 563 ms
60,016 KB |
testcase_18 | AC | 682 ms
60,820 KB |
testcase_19 | AC | 625 ms
60,200 KB |
testcase_20 | AC | 592 ms
60,072 KB |
testcase_21 | AC | 601 ms
60,024 KB |
testcase_22 | AC | 716 ms
60,600 KB |
testcase_23 | AC | 683 ms
60,420 KB |
testcase_24 | AC | 576 ms
60,576 KB |
testcase_25 | AC | 586 ms
60,176 KB |
testcase_26 | AC | 593 ms
61,020 KB |
ソースコード
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() + 1); 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 (t.charAt(j) == c[0]) { if (j >= c[1]) { if (t.charAt(j - c[1]) == c[0]) { hit = true; break LOOP; } } } if (t.charAt(j) == c[1]) { 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); } }