結果
問題 | No.483 マッチ並べ |
ユーザー | nanae |
提出日時 | 2017-02-11 13:11:38 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,744 bytes |
コンパイル時間 | 414 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-06-09 08:12:56 |
合計ジャッジ時間 | 2,762 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
10,880 KB |
testcase_01 | AC | 29 ms
10,880 KB |
testcase_02 | AC | 25 ms
11,008 KB |
testcase_03 | AC | 26 ms
11,008 KB |
testcase_04 | AC | 26 ms
10,880 KB |
testcase_05 | AC | 27 ms
10,752 KB |
testcase_06 | AC | 26 ms
10,880 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 26 ms
11,008 KB |
testcase_12 | AC | 26 ms
10,752 KB |
testcase_13 | AC | 25 ms
10,752 KB |
testcase_14 | AC | 26 ms
10,880 KB |
testcase_15 | WA | - |
testcase_16 | AC | 29 ms
10,880 KB |
testcase_17 | AC | 26 ms
11,008 KB |
testcase_18 | AC | 25 ms
10,880 KB |
testcase_19 | WA | - |
testcase_20 | AC | 26 ms
10,880 KB |
testcase_21 | AC | 25 ms
10,880 KB |
testcase_22 | AC | 26 ms
11,008 KB |
testcase_23 | AC | 27 ms
10,752 KB |
testcase_24 | AC | 27 ms
10,880 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 26 ms
10,880 KB |
testcase_28 | AC | 27 ms
11,008 KB |
testcase_29 | AC | 26 ms
10,880 KB |
testcase_30 | AC | 26 ms
10,880 KB |
testcase_31 | AC | 26 ms
11,008 KB |
testcase_32 | AC | 27 ms
10,752 KB |
testcase_33 | AC | 27 ms
10,880 KB |
testcase_34 | AC | 26 ms
11,008 KB |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 26 ms
10,752 KB |
testcase_40 | AC | 26 ms
11,008 KB |
testcase_41 | AC | 27 ms
10,880 KB |
testcase_42 | AC | 28 ms
10,880 KB |
testcase_43 | AC | 27 ms
11,008 KB |
testcase_44 | AC | 25 ms
10,880 KB |
testcase_45 | AC | 27 ms
11,008 KB |
testcase_46 | AC | 26 ms
11,008 KB |
testcase_47 | AC | 26 ms
10,880 KB |
testcase_48 | AC | 27 ms
10,880 KB |
testcase_49 | AC | 27 ms
10,752 KB |
testcase_50 | AC | 26 ms
10,880 KB |
testcase_51 | AC | 26 ms
11,008 KB |
testcase_52 | AC | 26 ms
10,880 KB |
testcase_53 | AC | 27 ms
10,752 KB |
testcase_54 | AC | 27 ms
10,880 KB |
testcase_55 | AC | 27 ms
10,880 KB |
ソースコード
import sys from collections import deque def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def paint_col(Adj, cols_v, cols_e, i, col): cols_v[i] = col nxts = deque([i]) while nxts: u = nxts.popleft() for v in Adj[u]: if cols_e[min(u, v), max(u, v)] == 0: cols_e[min(u, v), max(u, v)] = col if cols_v[v] == 0: cols_v[v] = col nxts.append(v) return None def solve(): N = int(input()) p2n = {} node = 0 Adj = [] cols_v = [] cols_e = {} for i in range(N): r0, c0, r1, c1 = map(int, input().split()) if (r0, c0) not in p2n: p2n[r0, c0] = node cols_v.append(0) node += 1 Adj.append([]) if (r1, c1) not in p2n: p2n[r1, c1] = node cols_v.append(0) node += 1 Adj.append([]) u, v = p2n[r0, c0], p2n[r1, c1] Adj[u].append(v) Adj[v].append(u) cols_e[min(u, v), max(u, v)] = 0 # debug(cols_v, locals()) # debug(cols_e, locals()) # debug(Adj, locals()) col = 1 for i in range(len(cols_v)): if cols_v[i] == 0: paint_col(Adj, cols_v, cols_e, i, col) col += 1 # debug(cols_v, locals()) # debug(cols_e, locals()) for c in range(1, col): num_v = sum(i == c for i in cols_v) num_e = sum(i == c for i in cols_e.values()) if num_v - num_e < 1: print('NO') break else: print('YES') if __name__ == '__main__': solve()