結果
| 問題 | 
                            No.629 グラフの中に眠る門松列
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-02-03 22:20:53 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 744 bytes | 
| コンパイル時間 | 540 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 22,272 KB | 
| 最終ジャッジ日時 | 2024-12-21 16:12:27 | 
| 合計ジャッジ時間 | 30,845 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / 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(0,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)