結果
問題 |
No.408 五輪ピック
|
ユーザー |
![]() |
提出日時 | 2024-05-04 03:23:11 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 221 ms / 5,000 ms |
コード長 | 912 bytes |
コンパイル時間 | 126 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 37,596 KB |
最終ジャッジ日時 | 2024-11-25 09:52:25 |
合計ジャッジ時間 | 5,051 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
ソースコード
import sys input = sys.stdin.readline N,M=map(int,input().split()) EDGE=[] for i in range(M): a,b=map(int,input().split()) a-=1 b-=1 EDGE.append((a,b)) E=[set() for i in range(N)] for a,b in EDGE: E[a].add(b) E[b].add(a) LIST=[] for to in E[0]: for toto in E[to]: if toto!=0: LIST.append((to,toto)) S=[set() for i in range(N)] for to,toto in LIST: S[toto].add(to) for a,b in EDGE: aflag=0 bflag=0 if b in S[a]: aflag=1 S[a].remove(b) if a in S[b]: bflag=1 S[b].remove(a) if len(S[a])==0 or len(S[b])==0: pass elif len(S[a])+len(S[b])>=3: print("YES") exit() else: x=list(S[a])[0] y=list(S[b])[0] if x!=y: print("YES") exit() if aflag==1: S[a].add(b) if bflag==1: S[b].add(a) print("NO")