結果
| 問題 | No.629 グラフの中に眠る門松列 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-02-04 21:41:34 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                TLE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 749 bytes | 
| コンパイル時間 | 615 ms | 
| コンパイル使用メモリ | 12,416 KB | 
| 実行使用メモリ | 11,520 KB | 
| 最終ジャッジ日時 | 2025-03-11 06:15:01 | 
| 合計ジャッジ時間 | 28,409 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 33 TLE * 3 | 
ソースコード
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)
            
            
            
        