結果
問題 | No.421 しろくろチョコレート |
ユーザー | htensai |
提出日時 | 2019-11-20 02:16:31 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,666 bytes |
コンパイル時間 | 1,991 ms |
コンパイル使用メモリ | 80,392 KB |
実行使用メモリ | 56,336 KB |
最終ジャッジ日時 | 2024-10-04 20:12:44 |
合計ジャッジ時間 | 12,436 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 128 ms
54,420 KB |
testcase_01 | WA | - |
testcase_02 | AC | 136 ms
54,088 KB |
testcase_03 | WA | - |
testcase_04 | AC | 122 ms
53,364 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 134 ms
54,380 KB |
testcase_09 | WA | - |
testcase_10 | AC | 116 ms
52,676 KB |
testcase_11 | WA | - |
testcase_12 | AC | 116 ms
54,604 KB |
testcase_13 | AC | 126 ms
54,172 KB |
testcase_14 | AC | 126 ms
54,128 KB |
testcase_15 | AC | 118 ms
53,080 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 114 ms
52,964 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 113 ms
52,836 KB |
testcase_24 | AC | 116 ms
52,696 KB |
testcase_25 | AC | 114 ms
54,188 KB |
testcase_26 | AC | 114 ms
52,944 KB |
testcase_27 | AC | 112 ms
53,152 KB |
testcase_28 | AC | 127 ms
53,784 KB |
testcase_29 | WA | - |
testcase_30 | AC | 122 ms
53,972 KB |
testcase_31 | AC | 124 ms
53,152 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 136 ms
54,620 KB |
testcase_35 | AC | 142 ms
54,032 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | AC | 128 ms
54,108 KB |
testcase_46 | AC | 129 ms
53,936 KB |
testcase_47 | WA | - |
testcase_48 | AC | 137 ms
54,388 KB |
testcase_49 | AC | 128 ms
53,068 KB |
testcase_50 | AC | 131 ms
54,076 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | AC | 130 ms
53,344 KB |
testcase_54 | AC | 129 ms
53,296 KB |
testcase_55 | WA | - |
testcase_56 | AC | 119 ms
53,128 KB |
testcase_57 | AC | 133 ms
54,276 KB |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | AC | 130 ms
54,304 KB |
testcase_63 | AC | 112 ms
52,980 KB |
testcase_64 | AC | 133 ms
54,440 KB |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) throws Exception { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int w = sc.nextInt(); char[][] field = new char[h + 2][]; int bCount = 0; int wCount = 0; for (int i = 0; i <= h + 1; i++) { if (i == 0 || i == h + 1) { field[i] = new char[w + 2]; Arrays.fill(field[i], '.'); continue; } field[i] = ("." + sc.next() + ".").toCharArray(); for (int j = 1; j <= w; j++) { if (field[i][j] == 'w') { wCount++; } else if (field[i][j] == 'b') { bCount++; } } } int[][] counts = new int[h + 2][w + 2]; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (field[i][j] != '.') { if (field[i - 1][j] != '.') { counts[i][j]++; } if (field[i + 1][j] != '.') { counts[i][j]++; } if (field[i][j - 1] != '.') { counts[i][j]++; } if (field[i][j + 1] != '.') { counts[i][j]++; } } } } boolean flag = true; int point = 0; while (flag) { flag = false; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (counts[i][j] == 1) { if (counts[i - 1][j] > 0) { counts[i - 1][j] = 0; counts[i][j] = 0; counts[i - 2][j]--; counts[i - 1][j - 1]--; counts[i - 1][j + 1]--; wCount--; bCount--; flag = true; point += 100; break; } if (counts[i + 1][j] > 0) { counts[i][j] = 0; counts[i + 1][j] = 0; counts[i + 2][j]--; counts[i + 1][j - 1]--; counts[i + 1][j + 1]--; wCount--; bCount--; flag = true; point += 100; break; } if (counts[i][j - 1] > 0) { counts[i][j] = 0; counts[i][j - 1] = 0; counts[i][j - 2]--; counts[i - 1][j - 1]--; counts[i + 1][j - 1]--; wCount--; bCount--; flag = true; point += 100; break; } if (counts[i][j + 1] > 0) { counts[i][j] = 0; counts[i][j + 1] = 0; counts[i][j + 2]--; counts[i - 1][j + 1]--; counts[i + 1][j + 1]--; wCount--; bCount--; flag = true; point += 100; break; } } } } } int allCount = 0; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (counts[i][j] > 0) { allCount++; } } } point += allCount / 2 * 100; bCount -= allCount / 2; wCount -= allCount / 2; int max = Math.max(wCount, bCount); int min = Math.min(wCount, bCount); point += 10 * min; point += max - min; System.out.println(point); } }