結果

問題 No.2085 Directed Complete Graph
ユーザー akakimidoriakakimidori
提出日時 2022-09-26 22:47:29
言語 Rust
(1.77.0)
結果
RE  
実行時間 -
コード長 1,066 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 149,700 KB
実行使用メモリ 24,396 KB
平均クエリ数 2355.41
最終ジャッジ日時 2023-08-24 03:14:32
合計ジャッジ時間 3,817 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,832 KB
testcase_01 AC 22 ms
23,484 KB
testcase_02 RE -
testcase_03 AC 151 ms
23,724 KB
testcase_04 RE -
testcase_05 AC 74 ms
23,592 KB
testcase_06 AC 81 ms
23,616 KB
testcase_07 AC 134 ms
23,628 KB
testcase_08 AC 105 ms
23,448 KB
testcase_09 AC 132 ms
24,012 KB
testcase_10 AC 138 ms
23,664 KB
testcase_11 AC 140 ms
24,252 KB
testcase_12 AC 141 ms
23,904 KB
testcase_13 AC 141 ms
23,364 KB
testcase_14 AC 139 ms
24,000 KB
testcase_15 AC 22 ms
24,036 KB
testcase_16 AC 23 ms
24,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let n = read();
    let mut p = (1..=n).collect::<Vec<_>>();
    p.sort_by(|a, b| {
        println!("? {} {}", *a, *b);
        let res = read();
        use std::cmp::Ordering::*;
        if res == 1 {
            Less
        } else {
            Greater
        }
    });
    println!("!");
    println!("{}", n - 1);
    use util::*;
    println!("{}", p.iter().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