結果
問題 |
No.483 マッチ並べ
|
ユーザー |
![]() |
提出日時 | 2024-09-21 15:19:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 486 bytes |
コンパイル時間 | 773 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 77,824 KB |
最終ジャッジ日時 | 2024-09-21 15:19:43 |
合計ジャッジ時間 | 5,812 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 53 |
ソースコード
def root(x): if r[x]!=x: r[x]=root(r[x]) return r[x] def union(x,y): rx=root(x) ry=root(y) if rx==ry: return if rx>ry: rx,ry=ry,rx r[ry]=rx return n=int(input()) L=111 r=list(range(L*L)) e=[0]*L*L for i in range(n): sx,sy,tx,ty=map(int,input().split()) s=sx*L+sy t=tx*L+ty e[s]+=1 e[t]+=1 union(s,t) p=[[] for i in range(L*L)] for i in range(L*L): p[root(i)]+=[i] f=1 for l in p: f&=1-len(l)+sum(e[i] for i in l)//2<2 print(["NO","YES"][f])