結果
問題 | No.179 塗り分け |
ユーザー | nbisco |
提出日時 | 2017-02-24 00:58:35 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 732 ms / 3,000 ms |
コード長 | 1,226 bytes |
コンパイル時間 | 256 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-07-23 14:42:04 |
合計ジャッジ時間 | 5,692 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
10,752 KB |
testcase_01 | AC | 30 ms
10,880 KB |
testcase_02 | AC | 29 ms
10,880 KB |
testcase_03 | AC | 31 ms
10,880 KB |
testcase_04 | AC | 30 ms
10,752 KB |
testcase_05 | AC | 30 ms
10,880 KB |
testcase_06 | AC | 30 ms
10,880 KB |
testcase_07 | AC | 30 ms
10,880 KB |
testcase_08 | AC | 29 ms
10,880 KB |
testcase_09 | AC | 28 ms
10,880 KB |
testcase_10 | AC | 29 ms
10,880 KB |
testcase_11 | AC | 30 ms
10,880 KB |
testcase_12 | AC | 732 ms
10,880 KB |
testcase_13 | AC | 30 ms
10,880 KB |
testcase_14 | AC | 29 ms
10,880 KB |
testcase_15 | AC | 29 ms
10,880 KB |
testcase_16 | AC | 29 ms
10,880 KB |
testcase_17 | AC | 29 ms
10,752 KB |
testcase_18 | AC | 37 ms
10,880 KB |
testcase_19 | AC | 36 ms
10,880 KB |
testcase_20 | AC | 30 ms
11,008 KB |
testcase_21 | AC | 30 ms
11,008 KB |
testcase_22 | AC | 79 ms
10,880 KB |
testcase_23 | AC | 29 ms
10,880 KB |
testcase_24 | AC | 63 ms
10,880 KB |
testcase_25 | AC | 31 ms
10,880 KB |
testcase_26 | AC | 35 ms
11,008 KB |
testcase_27 | AC | 210 ms
10,880 KB |
testcase_28 | AC | 39 ms
10,880 KB |
testcase_29 | AC | 347 ms
10,880 KB |
testcase_30 | AC | 172 ms
10,880 KB |
testcase_31 | AC | 452 ms
10,880 KB |
testcase_32 | AC | 123 ms
11,008 KB |
testcase_33 | AC | 443 ms
10,880 KB |
testcase_34 | AC | 99 ms
10,880 KB |
testcase_35 | AC | 534 ms
10,880 KB |
testcase_36 | AC | 29 ms
10,880 KB |
testcase_37 | AC | 29 ms
10,880 KB |
testcase_38 | AC | 30 ms
10,752 KB |
testcase_39 | AC | 30 ms
11,008 KB |
testcase_40 | AC | 30 ms
10,880 KB |
testcase_41 | AC | 29 ms
10,752 KB |
testcase_42 | AC | 30 ms
10,752 KB |
testcase_43 | AC | 37 ms
11,008 KB |
testcase_44 | AC | 67 ms
10,880 KB |
testcase_45 | AC | 31 ms
10,752 KB |
ソースコード
def move_ok(_S, H, W, count, diff): S = [[_S[i][j] for j in range(W)] for i in range(H)] for i in range(H): for j in range(W): if S[i][j] == ".": continue elif i+diff[0] < H and j+diff[1] < W \ and S[i+diff[0]][j+diff[1]] == "#": count -= 2 S[i+diff[0]][j+diff[1]] = "." return count == 0 def main(): H, W = map(int, input().split(" ")) S = [] for i in range(H): S.append(list(input())) start = [-1,-1] count = 0 for i in range(H): count += S[i].count("#") if start[0] == -1: for j in range(W): if S[i][j] == "#": start[0] = i start[1] = j break if count % 2 != 0: print("NO") return for i in range(H): for j in range(W): if start[0] == i and start[1] == j: continue if S[i][j] == ".": continue diff = (i-start[0], j-start[1]) if move_ok(S, H, W, count, diff): print("YES") return print("NO") if __name__ == "__main__": main()