結果

問題 No.483 マッチ並べ
ユーザー titiatitia
提出日時 2023-06-07 04:18:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 912 bytes
コンパイル時間 860 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 9,692 KB
最終ジャッジ日時 2023-08-28 12:08:45
合計ジャッジ時間 4,399 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
9,436 KB
testcase_01 AC 19 ms
9,508 KB
testcase_02 AC 23 ms
9,508 KB
testcase_03 AC 24 ms
9,644 KB
testcase_04 AC 24 ms
9,532 KB
testcase_05 AC 24 ms
9,592 KB
testcase_06 AC 19 ms
9,576 KB
testcase_07 AC 23 ms
9,512 KB
testcase_08 AC 24 ms
9,432 KB
testcase_09 AC 23 ms
9,472 KB
testcase_10 AC 24 ms
9,476 KB
testcase_11 AC 19 ms
9,540 KB
testcase_12 AC 19 ms
9,628 KB
testcase_13 AC 23 ms
9,628 KB
testcase_14 AC 24 ms
9,468 KB
testcase_15 AC 24 ms
9,508 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 24 ms
9,432 KB
testcase_19 AC 24 ms
9,572 KB
testcase_20 AC 19 ms
9,484 KB
testcase_21 AC 19 ms
9,488 KB
testcase_22 AC 18 ms
9,512 KB
testcase_23 AC 19 ms
9,620 KB
testcase_24 AC 19 ms
9,604 KB
testcase_25 AC 24 ms
9,588 KB
testcase_26 AC 23 ms
9,500 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 20 ms
9,596 KB
testcase_30 AC 24 ms
9,536 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 24 ms
9,568 KB
testcase_36 AC 24 ms
9,568 KB
testcase_37 AC 23 ms
9,572 KB
testcase_38 AC 24 ms
9,436 KB
testcase_39 AC 24 ms
9,492 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 24 ms
9,488 KB
testcase_44 AC 23 ms
9,504 KB
testcase_45 AC 24 ms
9,604 KB
testcase_46 AC 24 ms
9,436 KB
testcase_47 AC 24 ms
9,592 KB
testcase_48 AC 25 ms
9,568 KB
testcase_49 AC 23 ms
9,488 KB
testcase_50 AC 24 ms
9,580 KB
testcase_51 AC 23 ms
9,656 KB
testcase_52 AC 24 ms
9,488 KB
testcase_53 AC 24 ms
9,652 KB
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())

# UnionFind

Group = [i for i in range(20001)] # グループ分け
Nodes = [1]*(20001) # 各グループのノードの数

def find(x):
    while Group[x] != x:
        x=Group[x]
    return x

def Union(x,y):
    if find(x) != find(y):
        if Nodes[find(x)] < Nodes[find(y)]:
            
            Nodes[find(y)] += Nodes[find(x)]
            Nodes[find(x)] = 0
            Group[find(x)] = find(y)
            
        else:
            Nodes[find(x)] += Nodes[find(y)]
            Nodes[find(y)] = 0
            Group[find(y)] = find(x)

P=[list(map(int,input().split())) for i in range(N)]
for a,b,c,d in P:
    Union(a*110+b,c*110+d)

Point=[set()]*20001
Edge=[0]*20001

for a,b,c,d in P:
    x=find(a*110+b)
    Edge[x]+=1
    Point[x].add(a*110+b)
    Point[x].add(c*110+d)

for i in range(20001):
    if len(Point[i])+1<=Edge[i]:
        print("NO")
        exit()

print("YES")
0