結果
問題 |
No.421 しろくろチョコレート
|
ユーザー |
![]() |
提出日時 | 2019-01-26 13:39:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,180 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 82,704 KB |
実行使用メモリ | 80,580 KB |
最終ジャッジ日時 | 2024-09-16 04:56:15 |
合計ジャッジ時間 | 5,509 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 31 RE * 4 |
ソースコード
N,M = list(map(int, input().split(' '))) C = [] for _ in range(N): blocks = input() choco = [] for block in blocks: choco.append(block) C.append(choco) W = 0 B = 0 DX = [0, -1, 0, 1] DY = [-1, 0, 1, 0] def dfs(x,y): global W global B if C[x][y] == 'w': W = W + 1 elif C[x][y] == 'b': B = B + 1 C[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0 <= nx and nx < N and 0 <= ny and ny < M \ and (C[nx][ny] == 'w' or C[nx][ny] == 'b'): dfs(nx,ny) wbs = [] for i in range(N): for j in range(M): if C[i][j] != '.': W = 0 B = 0 dfs(i,j) wbs.append([W,B]) rows = 0 for wb in wbs: while 0 < wb[0] and 0 < wb[1]: wb[0] = wb[0] - 1 wb[1] = wb[1] - 1 rows = rows + 1 total_w = 0 total_b = 0 for wb in wbs: total_w = total_w + wb[0] total_b = total_b + wb[1] pairs = 0 while 0 < total_w and 0 < total_b: total_w = total_w - 1 total_b = total_b - 1 pairs = pairs + 1 print(rows * 100 + pairs * 10 + total_w + total_b)