結果

問題 No.2124 Guess the Permutation
ユーザー maguroflymagurofly
提出日時 2022-11-18 21:43:59
言語 Ruby
(3.3.0)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 295 bytes
コンパイル時間 475 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 32,488 KB
平均クエリ数 374.60
最終ジャッジ日時 2023-10-20 06:30:00
合計ジャッジ時間 2,405 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
32,488 KB
testcase_01 AC 120 ms
32,488 KB
testcase_02 AC 116 ms
32,488 KB
testcase_03 AC 121 ms
32,484 KB
testcase_04 AC 118 ms
32,488 KB
testcase_05 AC 133 ms
32,488 KB
testcase_06 AC 136 ms
32,488 KB
testcase_07 AC 159 ms
32,488 KB
testcase_08 AC 152 ms
32,488 KB
testcase_09 AC 152 ms
32,488 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

STDOUT.sync = true
N = gets.to_i

P = []
sum = (1 .. N).sum
(2 .. N - 1).reverse_each do |r|
  puts "? 1 #{r}"
  x = gets.to_i
  y = sum - x
  P.unshift(y)
  sum -= y
end
puts "? 2 #{N}"
x = gets.to_i
y = (1 .. N).sum - x
P.unshift((1 .. N).sum - P.sum - y)
P.unshift(y)

puts "! " + P.join(" ")
0