結果
| 問題 | No.629 グラフの中に眠る門松列 | 
| コンテスト | |
| ユーザー |  Bioinfo_K | 
| 提出日時 | 2018-01-05 23:22:57 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 44 ms / 4,000 ms | 
| コード長 | 821 bytes | 
| コンパイル時間 | 225 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 11,008 KB | 
| 最終ジャッジ日時 | 2024-12-23 07:19:29 | 
| 合計ジャッジ時間 | 2,857 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 36 | 
ソースコード
import sys,collections
from operator import itemgetter
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()
n,m = Is()
As = [0] + Is()
g = [[] for i in range(n+1)]
for i in range(m):
    u,v = Is()
    g[u].append(v)
    g[v].append(u)
for i,a in enumerate(As):
    if i == 0:
        continue
    if len(g[i]) >= 2:
        big,small = [],[]
        for e in g[i]:
            if As[e] > a:
                big.append(As[e])
            if As[e] < a:
                small.append(As[e])
#        print(a)
#        print(set(big))
#        print(set(small))
        if len(set(big)) >= 2 or len(set(small)) >= 2:
            print("YES")
            exit()
print("NO")
            
            
            
        