結果
問題 |
No.408 五輪ピック
|
ユーザー |
![]() |
提出日時 | 2024-05-04 03:22:49 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 912 bytes |
コンパイル時間 | 257 ms |
コンパイル使用メモリ | 82,428 KB |
実行使用メモリ | 90,676 KB |
最終ジャッジ日時 | 2024-11-25 09:51:57 |
合計ジャッジ時間 | 4,472 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 MLE * 8 |
ソースコード
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")