結果
| 問題 | No.2124 Guess the Permutation |
| コンテスト | |
| ユーザー |
Ricky_pon
|
| 提出日時 | 2022-11-18 21:32:50 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 655 bytes |
| 記録 | |
| コンパイル時間 | 3,123 ms |
| コンパイル使用メモリ | 201,604 KB |
| 実行使用メモリ | 30,064 KB |
| 平均クエリ数 | 374.60 |
| 最終ジャッジ日時 | 2026-04-08 14:29:53 |
| 合計ジャッジ時間 | 3,511 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
use std::io::stdin;
fn main() {
let n = read_int();
let mut p = vec![0; n];
p[0] = n * (n + 1) / 2 - interact(2, n);
for i in 1..=n - 2 {
p[i] = interact(i, i + 1) - p[i - 1];
}
p[n - 1] = n * (n + 1) / 2 - p.iter().sum::<usize>();
println!(
"! {}",
p.iter()
.map(|&x| x.to_string())
.collect::<Vec<_>>()
.join(" ")
);
}
fn interact(l: usize, r: usize) -> usize {
println!("? {} {}", l, r);
read_int()
}
fn read_int() -> usize {
let mut buf = String::new();
stdin().read_line(&mut buf).expect("input error!");
buf.trim().parse().unwrap()
}
Ricky_pon