結果

問題 No.2124 Guess the Permutation
ユーザー akakimidoriakakimidori
提出日時 2022-11-18 22:06:37
言語 Rust
(1.77.0)
結果
RE  
実行時間 -
コード長 927 bytes
コンパイル時間 1,123 ms
コンパイル使用メモリ 171,000 KB
実行使用メモリ 24,624 KB
平均クエリ数 1.00
最終ジャッジ日時 2023-10-20 06:55:42
合計ジャッジ時間 2,587 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let n = read();
    let mut s = vec![0; n + 1];
    s[n] = n * (n + 1) / 2;
    for i in 1..n {
        println!("? 1 {}", i);
        s[i] = read();
    }
    use util::*;
    println!("! {}", s.windows(2).map(|s| s[1] - s[0]).join(" "));
}

fn read() -> usize {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().unwrap()
}

mod util {
    pub trait Join {
        fn join(self, sep: &str) -> String;
    }

    impl<T, I> Join for I
    where
        I: Iterator<Item = T>,
        T: std::fmt::Display,
    {
        fn join(self, sep: &str) -> String {
            let mut s = String::new();
            use std::fmt::*;
            for (i, v) in self.enumerate() {
                if i > 0 {
                    write!(&mut s, "{}", sep).ok();
                }
                write!(&mut s, "{}", v).ok();
            }
            s
        }
    }
}

0