結果
| 問題 | No.629 グラフの中に眠る門松列 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-01-05 23:13:43 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 768 bytes | 
| コンパイル時間 | 240 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 19,968 KB | 
| 最終ジャッジ日時 | 2024-12-23 07:16:53 | 
| 合計ジャッジ時間 | 4,014 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 27 WA * 9 | 
ソースコード
from collections import deque
from collections import defaultdict
from collections import Counter
from itertools import permutations
def main():
    N, M = map(int, input().split())
    A = tuple(map(int, input().split()))
    UV = tuple(tuple(map(int, input().split())) for _ in [0] * M)
    a = dict()
    for i, j in enumerate(A):
        a[i+1] = j
    edge = [[0 for _ in [0] * (N + 1)] for _ in [0] * (N + 1)]
    for u, v in UV:
        edge[u][v] = edge[v][u] = 1
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            for k in range(1, N + 1):
                if a[i] != a[k]:
                    if a[i] < a[j] > a[k] or a[i] > a[j] < a[k]:
                        print('YES')
                        return
    print('NO')
main()
            
            
            
        