結果

問題 No.629 グラフの中に眠る門松列
ユーザー 👑 obakyanobakyan
提出日時 2019-04-03 16:58:24
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 970 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-21 15:53:05
合計ジャッジ時間 1,569 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,820 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 1 ms
6,816 KB
testcase_03 AC 2 ms
6,820 KB
testcase_04 AC 1 ms
6,816 KB
testcase_05 AC 1 ms
6,816 KB
testcase_06 AC 1 ms
6,816 KB
testcase_07 AC 1 ms
6,820 KB
testcase_08 AC 1 ms
6,816 KB
testcase_09 AC 2 ms
6,820 KB
testcase_10 AC 1 ms
6,820 KB
testcase_11 AC 1 ms
6,816 KB
testcase_12 AC 1 ms
6,816 KB
testcase_13 AC 1 ms
6,816 KB
testcase_14 WA -
testcase_15 AC 1 ms
6,820 KB
testcase_16 AC 2 ms
6,820 KB
testcase_17 AC 1 ms
6,820 KB
testcase_18 AC 1 ms
6,816 KB
testcase_19 AC 1 ms
6,816 KB
testcase_20 AC 2 ms
6,816 KB
testcase_21 WA -
testcase_22 AC 2 ms
6,820 KB
testcase_23 AC 2 ms
6,816 KB
testcase_24 AC 1 ms
6,816 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
6,816 KB
testcase_28 WA -
testcase_29 AC 2 ms
6,820 KB
testcase_30 AC 2 ms
6,816 KB
testcase_31 AC 2 ms
6,820 KB
testcase_32 AC 2 ms
6,820 KB
testcase_33 WA -
testcase_34 AC 2 ms
6,816 KB
testcase_35 AC 2 ms
6,816 KB
testcase_36 AC 3 ms
6,820 KB
testcase_37 WA -
testcase_38 AC 2 ms
6,816 KB
testcase_39 AC 2 ms
6,816 KB
testcase_40 WA -
testcase_41 AC 2 ms
6,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = io.read("*n", "*n")
nodes = {}
for i = 1, n do
    t = {}
    t["val"] = io.read("*n")
    t["count"] = 0
    nodes[i] = t
end
found = false
for i = 1, m do
    a, b = io.read("*n", "*n")
    ta, tb = nodes[a], nodes[b]
    cnt = ta["count"]
    if(cnt == 2) then
        found = true
        do break end
    else
        cnt = cnt + 1
        ta["count"], ta[cnt] = cnt, b
    end
    cnt = tb["count"]
    if(cnt == 2) then
        found = true
        do break end
    else
        cnt = cnt + 1
        tb["count"], tb[cnt] = cnt, a
    end
end
if(not found) then
    for i = 1, n do
        t = nodes[i]
        if(t["count"] == 2) then
            v = t["val"]
            v1t, v2t = nodes[t[1]], nodes[t[2]]
            v1, v2 = v1t["val"], v2t["val"]
            if(((v1 < v and v2 < v) or (v < v1 and v < v2)) and (v1 ~= v2)) then
                found = true
                break
            end
        end
    end
end
print (found and "YES" or "NO")
0