結果

問題 No.397 NO MORE KADOMATSU
ユーザー phsplsphspls
提出日時 2020-05-13 01:01:35
言語 Rust
(1.77.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 708 bytes
コンパイル時間 1,054 ms
コンパイル使用メモリ 142,616 KB
実行使用メモリ 24,384 KB
平均クエリ数 651.67
最終ジャッジ日時 2023-09-24 02:37:25
合計ジャッジ時間 2,712 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,060 KB
testcase_01 AC 22 ms
23,856 KB
testcase_02 AC 23 ms
23,448 KB
testcase_03 AC 24 ms
23,400 KB
testcase_04 AC 23 ms
24,096 KB
testcase_05 AC 24 ms
24,384 KB
testcase_06 AC 24 ms
24,060 KB
testcase_07 AC 24 ms
24,084 KB
testcase_08 AC 23 ms
23,448 KB
testcase_09 AC 22 ms
23,424 KB
testcase_10 AC 44 ms
24,096 KB
testcase_11 AC 21 ms
24,072 KB
testcase_12 AC 22 ms
23,556 KB
testcase_13 AC 30 ms
24,024 KB
testcase_14 AC 30 ms
24,336 KB
testcase_15 AC 30 ms
23,400 KB
testcase_16 AC 22 ms
23,664 KB
testcase_17 AC 22 ms
23,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let mut a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut result: Vec<(usize, usize)> = vec![];
    for i in 0..n {
        for j in i..n {
            if a[i] > a[j] {
                a.swap(i, j);
                result.push((i, j));
            }
        }
    }
    println!("{}", result.len());
    result.iter().for_each(|pair| println!("{} {}", pair.0, pair.1));

    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
}
0