結果

問題 No.629 グラフの中に眠る門松列
ユーザー maimai
提出日時 2017-04-30 01:14:19
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 1,076 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 11,208 KB
実行使用メモリ 15,628 KB
最終ジャッジ日時 2023-10-12 19:12:41
合計ジャッジ時間 6,102 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,072 KB
testcase_01 AC 81 ms
15,152 KB
testcase_02 AC 81 ms
15,260 KB
testcase_03 AC 81 ms
15,072 KB
testcase_04 AC 81 ms
15,044 KB
testcase_05 WA -
testcase_06 AC 80 ms
15,108 KB
testcase_07 AC 79 ms
15,148 KB
testcase_08 AC 79 ms
15,156 KB
testcase_09 WA -
testcase_10 AC 82 ms
15,304 KB
testcase_11 AC 80 ms
15,116 KB
testcase_12 WA -
testcase_13 AC 81 ms
15,316 KB
testcase_14 WA -
testcase_15 AC 80 ms
15,180 KB
testcase_16 AC 81 ms
15,348 KB
testcase_17 AC 82 ms
15,276 KB
testcase_18 AC 81 ms
15,264 KB
testcase_19 AC 82 ms
15,132 KB
testcase_20 AC 81 ms
15,168 KB
testcase_21 WA -
testcase_22 AC 85 ms
15,260 KB
testcase_23 AC 83 ms
15,008 KB
testcase_24 AC 89 ms
15,228 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 90 ms
15,540 KB
testcase_28 WA -
testcase_29 AC 88 ms
15,552 KB
testcase_30 AC 90 ms
15,512 KB
testcase_31 AC 90 ms
15,332 KB
testcase_32 AC 91 ms
15,496 KB
testcase_33 WA -
testcase_34 AC 90 ms
15,400 KB
testcase_35 AC 89 ms
15,288 KB
testcase_36 AC 92 ms
15,540 KB
testcase_37 WA -
testcase_38 AC 90 ms
15,264 KB
testcase_39 AC 88 ms
15,364 KB
testcase_40 WA -
testcase_41 AC 86 ms
15,296 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

line = gets.chomp!
abort "line 1 format error" unless line=~/^\d+ \d+$/
n,m = line.split.map &:to_i

line = gets.chomp!
abort "line 2 format error" unless line=~/^\d+(?: \d+)*$/
aa = line.split.map &:to_i
abort "line 2 vector_size error" unless aa.size == n

edges = []
m.times{|i|
    line = gets.chomp!
    abort "line #{i+3} format error" unless line=~/^\d+ \d+$/
    edges << line.split.map(&:to_i)
}
abort "too many lines" unless !gets


def yes;puts "YES";exit(0);end
def no ;puts "NO"; exit(0);end

def kadomatu?(a,b,c)
    a!=b&&b!=c&&c!=a&&((a<b&&b>c)||(a>b&&b<c))
end


# 辺集合から2つ選ぶ組み合わせを全列挙
edges.combination(2){|pair|
    
    if pair[0][0] == pair[1][0]
        # pair[0][1] -> (pair[0][0] == pair[1][0]) -> pair[1][1] となっているケース
        yes if kadomatu?(pair[0][1], pair[0][0], pair[1][1])
        
    elsif pair[0][0] == pair[1][1]
        # pair[0][1] -> (pair[0][0] == pair[1][1]) -> pair[1][0] となっているケース
        yes if kadomatu?(pair[0][1], pair[1][1], pair[1][0])
        
    end
}

no

0