結果
問題 | No.629 グラフの中に眠る門松列 |
ユーザー |
![]() |
提出日時 | 2023-01-15 01:49:40 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
MLE
|
実行時間 | - |
コード長 | 805 bytes |
コンパイル時間 | 227 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 821,248 KB |
最終ジャッジ日時 | 2024-12-26 15:18:04 |
合計ジャッジ時間 | 121,547 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | MLE * 6 |
other | AC * 1 MLE * 35 |
ソースコード
import sys sys.setrecursionlimit(10**7) readline = sys.stdin.readline def kadomatsu(a, b, c): for i in [-1, 1]: if a * i < b * i and b * i > c * i and a != c: return True return False def dfs(s, L, p=-1): if len(L) == 3: if kadomatsu(A[L[0]], A[L[1]], A[L[2]]): print("YES") exit() for u in G[s]: if u == p: continue L.append(u) dfs(u, L) L.pop() return N, M = map(int, readline().split()) A = list(map(int, readline().split())) G = [[] for i in range(N)] for i in range(M): u, v = map(int, readline().split()) u, v = u - 1, v - 1 if A[u] == A[v]: continue G[u].append(v) G[v].append(u) for i in range(N): dfs(i, [i]) print("NO")