結果

問題 No.629 グラフの中に眠る門松列
ユーザー GuestGuest
提出日時 2019-02-04 21:41:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 3,574 ms / 4,000 ms
コード長 749 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 10,848 KB
実行使用メモリ 9,516 KB
最終ジャッジ日時 2023-08-26 21:48:45
合計ジャッジ時間 23,039 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,048 KB
testcase_01 AC 15 ms
8,044 KB
testcase_02 AC 15 ms
7,996 KB
testcase_03 AC 15 ms
8,140 KB
testcase_04 AC 15 ms
8,140 KB
testcase_05 AC 15 ms
8,044 KB
testcase_06 AC 15 ms
8,112 KB
testcase_07 AC 15 ms
8,144 KB
testcase_08 AC 15 ms
8,056 KB
testcase_09 AC 15 ms
8,052 KB
testcase_10 AC 15 ms
7,996 KB
testcase_11 AC 15 ms
7,872 KB
testcase_12 AC 17 ms
8,140 KB
testcase_13 AC 15 ms
8,040 KB
testcase_14 AC 15 ms
7,964 KB
testcase_15 AC 15 ms
8,008 KB
testcase_16 AC 15 ms
8,024 KB
testcase_17 AC 15 ms
8,048 KB
testcase_18 AC 16 ms
8,056 KB
testcase_19 AC 16 ms
7,972 KB
testcase_20 AC 16 ms
8,188 KB
testcase_21 AC 775 ms
8,324 KB
testcase_22 AC 19 ms
8,280 KB
testcase_23 AC 410 ms
8,180 KB
testcase_24 AC 42 ms
9,400 KB
testcase_25 AC 3,323 ms
9,276 KB
testcase_26 AC 3,574 ms
9,280 KB
testcase_27 AC 1,685 ms
9,516 KB
testcase_28 AC 49 ms
8,324 KB
testcase_29 AC 98 ms
8,772 KB
testcase_30 AC 552 ms
9,312 KB
testcase_31 AC 204 ms
9,348 KB
testcase_32 AC 143 ms
9,392 KB
testcase_33 AC 3,203 ms
9,408 KB
testcase_34 AC 224 ms
8,992 KB
testcase_35 AC 53 ms
9,164 KB
testcase_36 AC 1,483 ms
9,328 KB
testcase_37 AC 1,500 ms
9,060 KB
testcase_38 AC 1,856 ms
9,320 KB
testcase_39 AC 317 ms
9,160 KB
testcase_40 AC 513 ms
8,636 KB
testcase_41 AC 37 ms
8,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def isTrees(x1, x2, x3):
  if x1 != x3 and ((x2 > x1 and x2 > x3) or (x2 < x1 and x2 < x3)):
      return True
  else:
    return False

n,m = input().split(' ')
a = []
a = input().split(' ')
v = []
for i in range(0,int(m)):
  v.append(input().split(' '))

result = 'NO'

for i in range(0,int(m)):
  for j in range(i + 1, int(m)):
    if i != j:
      if v[i][0] in v[j]:
        t = 1 if(v[j].index(v[i][0]) == 0) else 0
        if isTrees(a[int(v[j][t])-1], a[int(v[i][0])-1], a[int(v[i][1])-1]):
          result = 'YES'
      if v[i][1] in v[j]:
        t = 1 if(v[j].index(v[i][1]) == 0) else 0
        if isTrees(a[int(v[j][t])-1], a[int(v[i][1])-1], a[int(v[i][0])-1]):
          result = 'YES'
  if result == 'YES':
    break

print(result)
0