結果
問題 | No.307 最近色塗る問題多くない? |
ユーザー | nebukuro09 |
提出日時 | 2016-10-03 15:03:42 |
言語 | Python2 (2.7.18) |
結果 |
WA
|
実行時間 | - |
コード長 | 767 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 7,072 KB |
実行使用メモリ | 15,888 KB |
最終ジャッジ日時 | 2024-05-01 11:18:36 |
合計ジャッジ時間 | 6,170 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | TLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
ソースコード
dr = [0, 0, 1, -1] dc = [1, -1, 0, 0] H, W = map(int, raw_input().split()) board = [map(int, raw_input().split()) for _ in xrange(H)] Q = input() queries = [map(int, raw_input().split()) for _ in xrange(Q)] def dfs(r, c, color): visited = set() stack = [(r, c)] while len(stack) > 0: r, c = stack.pop() if (r, c) in visited or board[r][c] == color: continue visited.add((r, c)) board[r][c] = color for i in xrange(4): nr, nc = r+dr[i], c+dc[i] if nr < 0 or nr >= H or nc < 0 or nc >= W or (nr, nc) in visited: continue stack.append((nr, nc)) for q in queries: dfs(q[0]-1, q[1]-1, q[2]) for i in xrange(H): print ''.join(map(str, board[i]))