結果

問題 No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
ユーザー phsplsphspls
提出日時 2024-02-24 20:13:54
言語 Rust
(1.77.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 1,681 bytes
コンパイル時間 8,253 ms
コンパイル使用メモリ 183,676 KB
実行使用メモリ 26,680 KB
最終ジャッジ日時 2024-02-24 20:14:29
合計ジャッジ時間 27,193 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 93 ms
6,676 KB
testcase_02 AC 109 ms
6,676 KB
testcase_03 AC 87 ms
6,676 KB
testcase_04 AC 92 ms
6,676 KB
testcase_05 AC 92 ms
6,676 KB
testcase_06 AC 94 ms
6,676 KB
testcase_07 AC 101 ms
12,872 KB
testcase_08 AC 101 ms
12,444 KB
testcase_09 AC 104 ms
14,928 KB
testcase_10 AC 101 ms
13,664 KB
testcase_11 AC 97 ms
13,100 KB
testcase_12 AC 98 ms
14,688 KB
testcase_13 AC 106 ms
19,236 KB
testcase_14 AC 104 ms
25,372 KB
testcase_15 AC 97 ms
18,592 KB
testcase_16 AC 105 ms
14,684 KB
testcase_17 AC 110 ms
16,800 KB
testcase_18 AC 102 ms
17,632 KB
testcase_19 AC 104 ms
18,816 KB
testcase_20 AC 100 ms
26,152 KB
testcase_21 AC 104 ms
26,552 KB
testcase_22 AC 110 ms
26,264 KB
testcase_23 AC 98 ms
26,412 KB
testcase_24 AC 100 ms
26,252 KB
testcase_25 AC 102 ms
26,644 KB
testcase_26 AC 101 ms
26,392 KB
testcase_27 AC 109 ms
25,808 KB
testcase_28 AC 102 ms
26,284 KB
testcase_29 AC 101 ms
26,056 KB
testcase_30 AC 112 ms
26,660 KB
testcase_31 AC 104 ms
26,664 KB
testcase_32 AC 97 ms
26,668 KB
testcase_33 AC 103 ms
26,680 KB
testcase_34 AC 103 ms
26,668 KB
testcase_35 AC 110 ms
26,664 KB
testcase_36 AC 104 ms
26,676 KB
testcase_37 AC 104 ms
26,672 KB
testcase_38 AC 98 ms
26,664 KB
testcase_39 AC 105 ms
26,664 KB
testcase_40 AC 84 ms
23,172 KB
testcase_41 AC 80 ms
24,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut t = String::new();
    std::io::stdin().read_line(&mut t).ok();
    let t: usize = t.trim().parse().unwrap();
    for _ in 0..t {
        let mut nl = String::new();
        std::io::stdin().read_line(&mut nl).ok();
        let nl: Vec<usize> = nl.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let n = nl[0];
        let l = nl[1];
        let points = (0..n).map(|_| {
                let mut temmp = String::new();
                std::io::stdin().read_line(&mut temmp).ok();
                let temmp: Vec<usize> = temmp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
                (temmp[0], temmp[1])
            })
            .collect::<Vec<_>>();

        let unit = (l as f64 / (n as f64).sqrt()).ceil() as usize;
        let size = l / unit + if l % unit > 0 { 1 } else { 0 };
        let mut blocks = vec![vec![]; size];
        for &(x, y) in points.iter() {
            blocks[y/unit].push((x, y));
        }
        for i in 0..size {
            blocks[i].sort();
        }
        let mut result = Vec::with_capacity(n);
        let mut rev = false;
        for i in 0..size {
            if blocks[i].is_empty() { continue; }
            if rev {
                for &p in blocks[i].iter().rev() {
                    result.push(p);
                }
            } else {
                for &p in blocks[i].iter() {
                    result.push(p);
                }
            }
            rev = !rev;
        }
        println!("{n}");
        let result = result.into_iter().map(|p| format!("{} {}", p.0, p.1)).collect::<Vec<_>>();
        println!("{}", result.join("\n"));
    }
}
0