結果

問題 No.850 企業コンテスト2位
ユーザー betrue12betrue12
提出日時 2019-07-05 22:48:42
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 532 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 11,240 KB
実行使用メモリ 31,464 KB
平均クエリ数 230.54
最終ジャッジ日時 2023-09-23 17:34:34
合計ジャッジ時間 5,938 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
30,748 KB
testcase_01 AC 98 ms
30,564 KB
testcase_02 AC 96 ms
31,248 KB
testcase_03 AC 99 ms
31,216 KB
testcase_04 AC 94 ms
30,572 KB
testcase_05 AC 95 ms
31,312 KB
testcase_06 AC 97 ms
30,856 KB
testcase_07 AC 99 ms
30,904 KB
testcase_08 AC 105 ms
31,204 KB
testcase_09 AC 111 ms
31,220 KB
testcase_10 AC 118 ms
31,428 KB
testcase_11 AC 106 ms
31,404 KB
testcase_12 AC 106 ms
30,764 KB
testcase_13 AC 106 ms
31,180 KB
testcase_14 AC 107 ms
31,252 KB
testcase_15 AC 108 ms
30,888 KB
testcase_16 AC 107 ms
30,812 KB
testcase_17 AC 108 ms
31,148 KB
testcase_18 AC 107 ms
31,056 KB
testcase_19 AC 108 ms
31,296 KB
testcase_20 AC 110 ms
30,868 KB
testcase_21 AC 110 ms
30,780 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 95 ms
30,860 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

$t = 0

def ask(x, y)
    # $t += 1
    # ANS.each do |a|
    #     if a == x || a == y
    #         return a
    #     end
    # end
    # raise

    puts "? #{x} #{y}"
    STDOUT.flush
    return gets.to_i
end

N = gets.to_i
ANS = [0] + (1..N).to_a.shuffle

as = (1..N).to_a.shuffle
a1, a2 = as.shift(2)
a1, a2 = a2, a1 if ask(a1, a2) == a2
as.each do |a|
    if ask(a2, a) == a
        if ask(a1, a) == a
            a1, a2 = a, a1
        else
            a2 = a
        end
    end
end

puts "! #{a2}"

# puts ANS[2]
# puts $t
0