結果
| 問題 |
No.483 マッチ並べ
|
| コンテスト | |
| ユーザー |
compass19
|
| 提出日時 | 2017-02-16 23:57:24 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 1,127 bytes |
| コンパイル時間 | 296 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-12-30 01:35:44 |
| 合計ジャッジ時間 | 3,765 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 53 |
ソースコード
n = int(input())
node2con = dict()
con_data = dict()
con_num = 0
clear = True
for _ in range(n):
r0, c0, r1, c1 = map(int, input().split())
if not clear: continue
is_0 = (r0, c0) in node2con
is_1 = (r1, c1) in node2con
con0 = node2con[r0, c0] if is_0 else None
con1 = node2con[r1, c1] if is_1 else None
if is_0 and is_1:
if con0 == con1:
if con_data[con0]['roop']:
clear = False
else:
con_data[con0]['roop'] = True
else:
for node in con_data[con1]['node']:
node2con[node] = con0
con_data[con0]['node'].append(node)
con_data[con0]['roop'] |= con_data[con1]['roop']
elif is_0 and not is_1:
node2con[r1, c1] = con0
con_data[con0]['node'].append((r1, c1))
elif is_1 and not is_0:
node2con[r0, c0] = con1
con_data[con1]['node'].append((r0, c0))
else:
node2con[r0, c0] = node2con[r1, c1] = con_num
con_data[con_num] = {'node': [(r0, c0), (r1, c1)], 'roop': False}
con_num += 1
print(['NO', 'YES'][clear])
compass19