結果

問題 No.629 グラフの中に眠る門松列
ユーザー rlangevinrlangevin
提出日時 2023-01-15 01:45:15
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 799 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 77,020 KB
最終ジャッジ日時 2023-08-27 05:38:47
合計ジャッジ時間 8,586 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,208 KB
testcase_01 AC 71 ms
71,272 KB
testcase_02 AC 74 ms
71,208 KB
testcase_03 AC 71 ms
71,100 KB
testcase_04 AC 71 ms
71,388 KB
testcase_05 AC 73 ms
71,516 KB
testcase_06 AC 74 ms
71,392 KB
testcase_07 AC 72 ms
71,204 KB
testcase_08 AC 73 ms
71,272 KB
testcase_09 AC 73 ms
71,440 KB
testcase_10 AC 72 ms
71,344 KB
testcase_11 AC 72 ms
71,236 KB
testcase_12 AC 71 ms
71,512 KB
testcase_13 AC 73 ms
71,384 KB
testcase_14 AC 72 ms
71,224 KB
testcase_15 AC 72 ms
71,352 KB
testcase_16 AC 72 ms
71,232 KB
testcase_17 AC 73 ms
71,264 KB
testcase_18 AC 74 ms
71,340 KB
testcase_19 AC 73 ms
71,340 KB
testcase_20 AC 72 ms
71,088 KB
testcase_21 AC 367 ms
77,020 KB
testcase_22 AC 73 ms
71,064 KB
testcase_23 AC 74 ms
71,344 KB
testcase_24 AC 82 ms
76,412 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)
readline = sys.stdin.readline

def kadomatsu(a, b, c):
    for i in [-1, 1]:
        if a * i < b * i and b * i > c * i and a != c:
            return True
    return False

def dfs(s, L):
    if len(L) == 3:            
        if kadomatsu(A[L[0]], A[L[1]], A[L[2]]):
            print("YES")
            exit()
    for u in G[s]:
        if u in L:
            continue
        L.append(u)
        dfs(u, L)
        L.pop()
    return  
    


N, M = map(int, readline().split())
A = list(map(int, readline().split()))
G = [[] for i in range(N)]
for i in range(M):
    u, v = map(int, readline().split())
    u, v = u - 1, v - 1
    if A[u] == A[v]:
        continue
    G[u].append(v)
    G[v].append(u)
    
for i in range(N):
    dfs(i, [i])
print("NO")
0