結果
問題 | No.421 しろくろチョコレート |
ユーザー | 0w1 |
提出日時 | 2017-04-27 17:09:26 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,117 bytes |
コンパイル時間 | 430 ms |
コンパイル使用メモリ | 86,828 KB |
実行使用メモリ | 81,468 KB |
最終ジャッジ日時 | 2023-10-11 16:06:05 |
合計ジャッジ時間 | 10,162 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 116 ms
77,452 KB |
testcase_02 | AC | 104 ms
77,268 KB |
testcase_03 | AC | 79 ms
75,340 KB |
testcase_04 | AC | 95 ms
76,368 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 111 ms
78,012 KB |
testcase_08 | AC | 109 ms
77,264 KB |
testcase_09 | AC | 80 ms
75,100 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 75 ms
71,236 KB |
testcase_13 | AC | 75 ms
71,284 KB |
testcase_14 | WA | - |
testcase_15 | AC | 79 ms
71,356 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 74 ms
71,284 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 112 ms
77,556 KB |
testcase_23 | AC | 78 ms
71,196 KB |
testcase_24 | AC | 78 ms
71,388 KB |
testcase_25 | AC | 77 ms
71,296 KB |
testcase_26 | AC | 76 ms
71,144 KB |
testcase_27 | AC | 77 ms
71,184 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 104 ms
77,300 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 129 ms
79,916 KB |
testcase_41 | WA | - |
testcase_42 | AC | 92 ms
76,132 KB |
testcase_43 | AC | 104 ms
77,128 KB |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | AC | 114 ms
77,568 KB |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | AC | 96 ms
76,324 KB |
testcase_51 | AC | 183 ms
81,468 KB |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | AC | 114 ms
77,312 KB |
testcase_55 | AC | 83 ms
75,024 KB |
testcase_56 | AC | 82 ms
75,072 KB |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | AC | 79 ms
74,980 KB |
testcase_63 | AC | 80 ms
75,008 KB |
testcase_64 | AC | 107 ms
77,612 KB |
ソースコード
from itertools import product dx = [ 0, 1, 0, -1 ] dy = [ 1, 0, -1, 0 ] N, M = map( int, input().split() ) G = [ input() for i in range( N ) ] adj = [ [] for i in range( N * M ) ] for i in range( N ): for j in range( M ): if G[ i ][ j ] in "b.": continue for di in range( 4 ): ni, nj = i + dx[ di ], j + dy[ di ] if not ( 0 <= ni and ni < N and 0 <= nj and nj < M ): continue if G[ ni ][ nj ] == '.': continue adj[ i * M + j ].append( ni * M + nj ) def find_mate( u, bf, vis = None ): if vis is None: vis = [ False for i in range( N * M ) ] for v in adj[ u ]: if vis[ v ]: continue vis[ v ] = True if bf[ v ] == -1 or find_mate( bf[ v ], bf, vis ): bf[ v ] = u return True return False bf = [ -1 for i in range( N * M ) ] match_cnt = 0 for i in range( 0, N * M, 2 ): match_cnt += find_mate( i, bf ) rw = sum( G[ i ][ j ] == 'w' for i, j in product( range( N ), range( M ) ) ) - match_cnt rb = sum( G[ i ][ j ] == 'b' for i, j in product( range( N ), range( M ) ) ) - match_cnt print( match_cnt * 100 + min( rw, rb ) * 10 + abs( rw - rb ) )