結果

問題 No.629 グラフの中に眠る門松列
ユーザー pluto77
提出日時 2018-01-23 12:08:14
言語 Python2
(2.7.18)
結果
AC  
実行時間 23 ms / 4,000 ms
コード長 403 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 7,076 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-12-26 02:58:26
合計ジャッジ時間 2,106 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki629

N,M=map(int,raw_input().split())
A=map(int,raw_input().split())
E=[[] for i in xrange(N)]
for i in xrange(M):
 a,b=map(int,raw_input().split())
 a,b=a-1,b-1
 E[a].append(b)
 E[b].append(a)
res='NO'
for cu in xrange(N):
 up=set()
 dn=set()
 for to in E[cu]:
  if A[cu]<A[to]:
   up.add(A[to])
  if A[cu]>A[to]:
   dn.add(A[to])
 if len(up)>=2:
  res='YES'
 if len(dn)>=2:
  res='YES'
print res
0