結果

問題 No.483 マッチ並べ
ユーザー kohei2019kohei2019
提出日時 2022-07-27 00:50:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 86,428 KB
実行使用メモリ 71,548 KB
最終ジャッジ日時 2023-09-23 14:34:56
合計ジャッジ時間 7,552 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
71,544 KB
testcase_01 AC 85 ms
71,356 KB
testcase_02 AC 85 ms
71,040 KB
testcase_03 AC 81 ms
71,140 KB
testcase_04 AC 83 ms
71,308 KB
testcase_05 AC 83 ms
71,264 KB
testcase_06 AC 82 ms
71,544 KB
testcase_07 AC 84 ms
71,356 KB
testcase_08 AC 86 ms
71,408 KB
testcase_09 AC 85 ms
71,280 KB
testcase_10 AC 84 ms
71,220 KB
testcase_11 AC 85 ms
71,436 KB
testcase_12 AC 84 ms
71,280 KB
testcase_13 AC 85 ms
71,252 KB
testcase_14 AC 86 ms
71,516 KB
testcase_15 AC 82 ms
71,480 KB
testcase_16 AC 83 ms
71,400 KB
testcase_17 AC 83 ms
71,264 KB
testcase_18 AC 83 ms
71,520 KB
testcase_19 AC 84 ms
71,408 KB
testcase_20 AC 84 ms
71,268 KB
testcase_21 AC 86 ms
71,244 KB
testcase_22 AC 83 ms
71,436 KB
testcase_23 AC 85 ms
71,148 KB
testcase_24 AC 87 ms
71,304 KB
testcase_25 AC 84 ms
71,400 KB
testcase_26 AC 89 ms
71,384 KB
testcase_27 AC 87 ms
71,356 KB
testcase_28 AC 87 ms
71,472 KB
testcase_29 AC 83 ms
71,320 KB
testcase_30 AC 86 ms
71,468 KB
testcase_31 AC 87 ms
71,260 KB
testcase_32 AC 87 ms
71,400 KB
testcase_33 AC 85 ms
71,412 KB
testcase_34 AC 86 ms
71,320 KB
testcase_35 AC 91 ms
70,972 KB
testcase_36 AC 87 ms
71,516 KB
testcase_37 AC 85 ms
70,924 KB
testcase_38 AC 87 ms
71,352 KB
testcase_39 AC 87 ms
71,280 KB
testcase_40 AC 88 ms
71,352 KB
testcase_41 AC 85 ms
71,544 KB
testcase_42 AC 86 ms
71,036 KB
testcase_43 AC 85 ms
71,248 KB
testcase_44 AC 81 ms
71,280 KB
testcase_45 AC 82 ms
71,044 KB
testcase_46 AC 82 ms
71,252 KB
testcase_47 AC 85 ms
71,380 KB
testcase_48 AC 87 ms
71,328 KB
testcase_49 AC 94 ms
70,920 KB
testcase_50 AC 92 ms
71,284 KB
testcase_51 AC 84 ms
71,520 KB
testcase_52 AC 85 ms
71,548 KB
testcase_53 AC 82 ms
70,928 KB
testcase_54 AC 86 ms
71,248 KB
testcase_55 AC 87 ms
71,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
N = int(input())
lsg = collections.defaultdict(list)
node = []
for i in range(N):
    r1,c1,r2,c2 = map(int,input().split())
    lsg[(r1,c1)].append((r2,c2))
    lsg[(r2,c2)].append((r1,c1))
    node.append((r1,c1))
    node.append((r2,c2))
used = collections.defaultdict(lambda :False)
ans = True
for x,y in node:
    if used[(x,y)]:
        continue
    d = collections.deque([(x,y)])
    roop = 0
    while d:
        x,y = d.pop()
        if used[(x,y)]:
            continue
        used[(x,y)] = True
        c = 0
        for xn,yn in lsg[(x,y)]:
            if used[(xn,yn)]:
                c += 1
                continue
            d.append((xn,yn))
        if c >= 2:
            roop += c-1
    if roop >= 2:
        ans = False
print('YES' if ans else 'NO')
0