結果
問題 | No.421 しろくろチョコレート |
ユーザー | htensai |
提出日時 | 2019-11-20 02:16:31 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,666 bytes |
コンパイル時間 | 2,259 ms |
コンパイル使用メモリ | 79,504 KB |
実行使用メモリ | 56,460 KB |
最終ジャッジ日時 | 2024-04-15 06:32:37 |
合計ジャッジ時間 | 14,273 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 152 ms
54,440 KB |
testcase_01 | WA | - |
testcase_02 | AC | 156 ms
54,048 KB |
testcase_03 | WA | - |
testcase_04 | AC | 156 ms
54,424 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 156 ms
54,408 KB |
testcase_09 | WA | - |
testcase_10 | AC | 155 ms
54,308 KB |
testcase_11 | WA | - |
testcase_12 | AC | 146 ms
54,240 KB |
testcase_13 | AC | 145 ms
54,300 KB |
testcase_14 | AC | 145 ms
54,440 KB |
testcase_15 | AC | 147 ms
54,416 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 146 ms
54,228 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 150 ms
54,444 KB |
testcase_24 | AC | 146 ms
54,344 KB |
testcase_25 | AC | 148 ms
54,256 KB |
testcase_26 | AC | 147 ms
54,312 KB |
testcase_27 | AC | 148 ms
54,280 KB |
testcase_28 | AC | 172 ms
54,280 KB |
testcase_29 | WA | - |
testcase_30 | AC | 157 ms
54,028 KB |
testcase_31 | AC | 155 ms
54,056 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 154 ms
54,432 KB |
testcase_35 | AC | 153 ms
54,132 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 | 156 ms
54,424 KB |
testcase_46 | AC | 152 ms
54,464 KB |
testcase_47 | WA | - |
testcase_48 | AC | 154 ms
54,540 KB |
testcase_49 | AC | 154 ms
54,524 KB |
testcase_50 | AC | 152 ms
54,308 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | AC | 153 ms
54,136 KB |
testcase_54 | AC | 152 ms
54,256 KB |
testcase_55 | WA | - |
testcase_56 | AC | 151 ms
54,460 KB |
testcase_57 | AC | 155 ms
54,240 KB |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | AC | 157 ms
54,008 KB |
testcase_63 | AC | 147 ms
54,244 KB |
testcase_64 | AC | 156 ms
54,720 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); } }