結果
問題 |
No.408 五輪ピック
|
ユーザー |
![]() |
提出日時 | 2025-06-12 13:57:41 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,148 bytes |
コンパイル時間 | 197 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 131,072 KB |
最終ジャッジ日時 | 2025-06-12 13:58:10 |
合計ジャッジ時間 | 9,199 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 MLE * 7 -- * 4 |
ソースコード
import sys from collections import defaultdict def main(): N, M = map(int, sys.stdin.readline().split()) adj = defaultdict(list) for _ in range(M): a, b = map(int, sys.stdin.readline().split()) adj[a].append(b) adj[b].append(a) # Get neighbors of vertex 1 S = adj[1] if not S: print("NO") return S_set = set(S) # Check each neighbor u of 1 for u in S: # Check all neighbors a of u (excluding 1) for a in adj[u]: if a == 1: continue # Check all neighbors b of a (excluding 1 and u) for b in adj[a]: if b == 1 or b == u: continue # Check all neighbors x of b (excluding 1) for x in adj[b]: if x == 1: continue # Check if x is a neighbor of 1 and distinct from u, a, b if x in S_set and x != u and x != a and x != b: print("YES") return print("NO") if __name__ == "__main__": main()