結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,752 KB
testcase_01 AC 19 ms
8,792 KB
testcase_02 AC 21 ms
8,860 KB
testcase_03 AC 20 ms
8,788 KB
testcase_04 AC 22 ms
8,864 KB
testcase_05 AC 21 ms
8,848 KB
testcase_06 AC 19 ms
8,820 KB
testcase_07 AC 21 ms
8,712 KB
testcase_08 AC 21 ms
8,932 KB
testcase_09 AC 21 ms
8,768 KB
testcase_10 AC 21 ms
8,748 KB
testcase_11 AC 18 ms
8,768 KB
testcase_12 AC 18 ms
8,800 KB
testcase_13 AC 21 ms
8,884 KB
testcase_14 AC 21 ms
8,772 KB
testcase_15 AC 22 ms
8,768 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 21 ms
8,752 KB
testcase_19 AC 21 ms
8,740 KB
testcase_20 AC 19 ms
8,812 KB
testcase_21 AC 19 ms
8,752 KB
testcase_22 AC 19 ms
8,740 KB
testcase_23 AC 19 ms
8,716 KB
testcase_24 AC 19 ms
8,936 KB
testcase_25 AC 22 ms
8,740 KB
testcase_26 AC 21 ms
8,772 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 20 ms
8,884 KB
testcase_30 AC 22 ms
8,876 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 21 ms
8,752 KB
testcase_36 AC 21 ms
8,740 KB
testcase_37 AC 22 ms
8,740 KB
testcase_38 AC 22 ms
8,800 KB
testcase_39 AC 22 ms
8,884 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 RE -
testcase_44 AC 21 ms
8,796 KB
testcase_45 AC 21 ms
8,788 KB
testcase_46 AC 21 ms
8,824 KB
testcase_47 AC 20 ms
8,860 KB
testcase_48 AC 22 ms
8,716 KB
testcase_49 AC 21 ms
8,800 KB
testcase_50 AC 22 ms
8,716 KB
testcase_51 AC 21 ms
8,916 KB
testcase_52 AC 22 ms
8,740 KB
testcase_53 AC 21 ms
8,712 KB
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())

# UnionFind

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

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*100+b,c*100+d)

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

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

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

print("YES")
0