結果

問題 No.629 グラフの中に眠る門松列
ユーザー KozumaKozuma
提出日時 2018-01-16 15:42:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 558 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2023-08-25 18:42:55
合計ジャッジ時間 8,505 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,764 KB
testcase_01 AC 15 ms
7,960 KB
testcase_02 AC 16 ms
7,884 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 15 ms
7,880 KB
testcase_06 AC 15 ms
7,800 KB
testcase_07 AC 14 ms
7,804 KB
testcase_08 AC 15 ms
7,784 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 15 ms
7,764 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 15 ms
7,864 KB
testcase_21 AC 51 ms
8,288 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 38 ms
8,208 KB
testcase_25 AC 568 ms
8,244 KB
testcase_26 AC 579 ms
8,316 KB
testcase_27 AC 511 ms
8,404 KB
testcase_28 AC 21 ms
7,800 KB
testcase_29 AC 119 ms
8,512 KB
testcase_30 WA -
testcase_31 AC 418 ms
8,508 KB
testcase_32 WA -
testcase_33 AC 558 ms
8,564 KB
testcase_34 AC 57 ms
8,456 KB
testcase_35 AC 184 ms
8,440 KB
testcase_36 WA -
testcase_37 AC 278 ms
8,372 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 103 ms
8,404 KB
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def kadomatu(x, y, z):
	if x != y and y != z and z != x:
		if (y < x and y < z) or (y > x and y > z):
			return True

def check():
	N, M = map(int, input().split())
	a = list(map(int, input().split()))
	u = [0] * M
	v = [0] * M

	for i in range(M):
		u[i], v[i] = map(int, input().split())

	for i in range(M):
		for j in range(i + 1, M):
			if u[j] == v[i]:
				if kadomatu(a[u[i]-1], a[v[i]-1], a[v[j]-1]):
					return True
			if v[j] == v[i]:
				if kadomatu(a[u[i]-1], a[v[i]-1], a[u[i]-1]):
					return True

if check():
	print("YES")
else:
	print("NO")
0