結果
| 問題 | No.408 五輪ピック |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-16 16:40:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,121 bytes |
| 記録 | |
| コンパイル時間 | 373 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 96,560 KB |
| 最終ジャッジ日時 | 2025-04-16 16:41:35 |
| 合計ジャッジ時間 | 9,267 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 MLE * 10 -- * 4 |
ソースコード
def main():
import sys
input = sys.stdin.read().split()
idx = 0
N = int(input[idx])
idx += 1
M = int(input[idx])
idx += 1
adj = [set() for _ in range(N + 1)]
for _ in range(M):
u = int(input[idx])
idx += 1
v = int(input[idx])
idx += 1
adj[u].add(v)
adj[v].add(u)
S = adj[1]
if not S:
print("NO")
return
# Precompute S as a set for faster lookups
S_set = S
for x in S:
# Iterate through all a adjacent to x (excluding 1 and x)
for a in adj[x]:
if a == 1 or a == x:
continue
# Iterate through all b adjacent to a (excluding 1, x, a)
for b in adj[a]:
if b == 1 or b == x or b == a:
continue
# Iterate through all y adjacent to b (check if y is in S and not x, a, b)
for y in adj[b]:
if y in S_set and y not in {x, a, b}:
print("YES")
return
print("NO")
if __name__ == "__main__":
main()
lam6er