結果

問題 No.421 しろくろチョコレート
ユーザー MitI_7MitI_7
提出日時 2016-10-02 16:47:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,455 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-05-01 09:36:47
合計ジャッジ時間 32,892 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 222 ms
10,752 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 26 ms
10,752 KB
testcase_13 AC 25 ms
10,752 KB
testcase_14 AC 27 ms
10,752 KB
testcase_15 AC 28 ms
10,880 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 28 ms
10,752 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 28 ms
10,880 KB
testcase_24 AC 28 ms
10,880 KB
testcase_25 AC 27 ms
10,880 KB
testcase_26 AC 28 ms
10,880 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 TLE -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 109 ms
10,752 KB
testcase_35 AC 126 ms
10,752 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 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 28 ms
11,008 KB
testcase_63 AC 27 ms
10,752 KB
testcase_64 AC 28 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def solve(n, m, chocolate):
    ans = 0
    while True:

        min_num = 5
        min_pos = (None, None)
        for y in range(n):
            for x in range(m):
                now = chocolate[y][x]

                num = 0
                for i in range(len(dy)):
                    ny, nx = y + dy[i], x + dx[i]
                    if 0 <= ny < n and 0 <= nx < m:
                        if now != "." and chocolate[ny][nx] != "." and chocolate[ny][nx] != now:
                            num += 1

                if num != 0 and num < min_num:
                    min_num = num
                    min_pos = (y, x)

        if min_num == 5:
            break

        y, x = min_pos
        for i in range(len(dy)):
            ny, nx = y + dy[i], x + dx[i]
            if 0 <= ny < n and 0 <= nx < m:
                if chocolate[ny][nx] != ".":
                    chocolate[y][x] = "."
                    chocolate[ny][nx] = "."
                    ans += 100

    w, b = 0, 0
    for y in range(n):
        for x in range(m):
            now = chocolate[y][x]
            w += now == "w"
            b += now == "b"

    ans += min(w, b) * 10
    ans += max(w, b) - min(w, b)
    return ans


def main():
    n, m = map(int, input().split())
    chocolate = []
    for _ in range(n):
        chocolate.append(list(input()))

    print(solve(n, m, chocolate))



if __name__ == '__main__':
    main()
0