結果
問題 | No.629 グラフの中に眠る門松列 |
ユーザー | wajima_wataru |
提出日時 | 2018-01-05 22:01:58 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 45 ms / 4,000 ms |
コード長 | 537 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-12-23 06:37:57 |
合計ジャッジ時間 | 3,217 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 36 |
ソースコード
N, M = map(int, input().split()) a = list(map(int, input().split())) g = [[] for _ in range(N)] for i in range(M): u, v = map(int, input().split()) if not a[u - 1] == a[v - 1]: g[u - 1].append(a[v - 1]) g[v - 1].append(a[u - 1]) for i, n in enumerate(g): ns = list(set(g[i])) length = len(ns) if length > 2: print('YES') exit() elif length == 2: if (ns[0] < a[i] and ns[1] < a[i]) or (ns[0] > a[i] and ns[1] > a[i]): print('YES') exit() print('NO')