結果
問題 |
No.629 グラフの中に眠る門松列
|
ユーザー |
![]() |
提出日時 | 2022-11-29 06:55:53 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 40 ms / 4,000 ms |
コード長 | 633 bytes |
コンパイル時間 | 88 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-10-06 14:02:49 |
合計ジャッジ時間 | 2,729 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 36 |
ソースコード
from collections import defaultdict def main(): n, m = map(int, input().split()) a = [0] + list(map(int, input().split())) adj = defaultdict(set) for _ in range(m): fr, to = map(int, input().split()) if a[fr] != a[to]: adj[fr].add(to) adj[to].add(fr) for i in range(n + 1): if len(adj[i]) < 2: continue big = len(set([a[x] for x in adj[i] if a[x] > a[i]])) small = len(set([a[x] for x in adj[i] if a[x] < a[i]])) if big > 1 or small > 1: exit(print("YES")) print("NO") if __name__ == "__main__": main()