結果

問題 No.5010 Better Mo's Algorithm is Needed!! (Unweighted)
ユーザー akakimidoriakakimidori
提出日時 2022-12-17 00:08:05
言語 Rust
(1.77.0 + proconio)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 2,639 bytes
コンパイル時間 1,579 ms
実行使用メモリ 13,524 KB
スコア 16,092,404,691
最終ジャッジ日時 2022-12-17 00:09:24
合計ジャッジ時間 70,866 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
13,460 KB
testcase_01 AC 125 ms
13,360 KB
testcase_02 AC 128 ms
13,344 KB
testcase_03 AC 129 ms
13,372 KB
testcase_04 AC 126 ms
13,412 KB
testcase_05 AC 125 ms
13,396 KB
testcase_06 AC 129 ms
13,296 KB
testcase_07 AC 132 ms
13,400 KB
testcase_08 AC 129 ms
13,392 KB
testcase_09 AC 126 ms
13,260 KB
testcase_10 AC 124 ms
13,308 KB
testcase_11 AC 127 ms
13,328 KB
testcase_12 AC 125 ms
13,308 KB
testcase_13 AC 126 ms
13,380 KB
testcase_14 AC 126 ms
13,444 KB
testcase_15 AC 129 ms
13,444 KB
testcase_16 AC 126 ms
13,372 KB
testcase_17 AC 125 ms
13,332 KB
testcase_18 AC 128 ms
13,432 KB
testcase_19 AC 125 ms
13,324 KB
testcase_20 AC 126 ms
13,332 KB
testcase_21 AC 126 ms
13,508 KB
testcase_22 AC 127 ms
13,408 KB
testcase_23 AC 126 ms
13,400 KB
testcase_24 AC 128 ms
13,296 KB
testcase_25 AC 126 ms
13,372 KB
testcase_26 AC 131 ms
13,408 KB
testcase_27 AC 127 ms
13,420 KB
testcase_28 AC 127 ms
13,444 KB
testcase_29 AC 127 ms
13,360 KB
testcase_30 AC 130 ms
13,412 KB
testcase_31 AC 130 ms
13,440 KB
testcase_32 AC 128 ms
13,436 KB
testcase_33 AC 123 ms
13,376 KB
testcase_34 AC 133 ms
13,264 KB
testcase_35 AC 127 ms
13,260 KB
testcase_36 AC 135 ms
13,336 KB
testcase_37 AC 126 ms
13,444 KB
testcase_38 AC 125 ms
13,380 KB
testcase_39 AC 130 ms
13,300 KB
testcase_40 AC 127 ms
13,336 KB
testcase_41 AC 125 ms
13,428 KB
testcase_42 AC 123 ms
13,488 KB
testcase_43 AC 123 ms
13,272 KB
testcase_44 AC 128 ms
13,336 KB
testcase_45 AC 129 ms
13,300 KB
testcase_46 AC 128 ms
13,408 KB
testcase_47 AC 125 ms
13,404 KB
testcase_48 AC 133 ms
13,320 KB
testcase_49 AC 127 ms
13,432 KB
testcase_50 AC 125 ms
13,260 KB
testcase_51 AC 125 ms
13,376 KB
testcase_52 AC 123 ms
13,324 KB
testcase_53 AC 125 ms
13,492 KB
testcase_54 AC 127 ms
13,404 KB
testcase_55 AC 126 ms
13,412 KB
testcase_56 AC 123 ms
13,264 KB
testcase_57 AC 127 ms
13,364 KB
testcase_58 AC 125 ms
13,524 KB
testcase_59 AC 126 ms
13,368 KB
testcase_60 AC 124 ms
13,444 KB
testcase_61 AC 124 ms
13,520 KB
testcase_62 AC 126 ms
13,336 KB
testcase_63 AC 128 ms
13,420 KB
testcase_64 AC 125 ms
13,432 KB
testcase_65 AC 126 ms
13,372 KB
testcase_66 AC 128 ms
13,444 KB
testcase_67 AC 126 ms
13,404 KB
testcase_68 AC 124 ms
13,400 KB
testcase_69 AC 126 ms
13,416 KB
testcase_70 AC 128 ms
13,372 KB
testcase_71 AC 128 ms
13,424 KB
testcase_72 AC 123 ms
13,408 KB
testcase_73 AC 125 ms
13,260 KB
testcase_74 AC 130 ms
13,428 KB
testcase_75 AC 127 ms
13,416 KB
testcase_76 AC 128 ms
13,504 KB
testcase_77 AC 128 ms
13,400 KB
testcase_78 AC 128 ms
13,260 KB
testcase_79 AC 129 ms
13,364 KB
testcase_80 AC 129 ms
13,388 KB
testcase_81 AC 124 ms
13,408 KB
testcase_82 AC 124 ms
13,516 KB
testcase_83 AC 130 ms
13,332 KB
testcase_84 AC 123 ms
13,260 KB
testcase_85 AC 125 ms
13,480 KB
testcase_86 AC 127 ms
13,500 KB
testcase_87 AC 129 ms
13,512 KB
testcase_88 AC 128 ms
13,416 KB
testcase_89 AC 129 ms
13,380 KB
testcase_90 AC 128 ms
13,376 KB
testcase_91 AC 127 ms
13,392 KB
testcase_92 AC 126 ms
13,392 KB
testcase_93 AC 130 ms
13,512 KB
testcase_94 AC 126 ms
13,304 KB
testcase_95 AC 123 ms
13,380 KB
testcase_96 AC 126 ms
13,256 KB
testcase_97 AC 127 ms
13,280 KB
testcase_98 AC 127 ms
13,440 KB
testcase_99 AC 125 ms
13,304 KB
testcase_100 AC 127 ms
13,440 KB
testcase_101 AC 128 ms
13,260 KB
testcase_102 AC 126 ms
13,380 KB
testcase_103 AC 128 ms
13,396 KB
testcase_104 AC 123 ms
13,320 KB
testcase_105 AC 121 ms
13,368 KB
testcase_106 AC 127 ms
13,348 KB
testcase_107 AC 125 ms
13,372 KB
testcase_108 AC 125 ms
13,416 KB
testcase_109 AC 128 ms
13,360 KB
testcase_110 AC 132 ms
13,320 KB
testcase_111 AC 124 ms
13,376 KB
testcase_112 AC 125 ms
13,416 KB
testcase_113 AC 124 ms
13,264 KB
testcase_114 AC 123 ms
13,432 KB
testcase_115 AC 124 ms
13,416 KB
testcase_116 AC 125 ms
13,440 KB
testcase_117 AC 123 ms
13,496 KB
testcase_118 AC 130 ms
13,308 KB
testcase_119 AC 123 ms
13,424 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::io::Write`
 --> Main.rs:1:5
  |
1 | use std::io::Write;
  |     ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: type alias is never used: `Map`
 --> Main.rs:4:1
  |
4 | type Map<K, V> = BTreeMap<K, V>;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: type alias is never used: `Set`
 --> Main.rs:5:1
  |
5 | type Set<T> = BTreeSet<T>;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type alias is never used: `Deque`
 --> Main.rs:6:1
  |
6 | type Deque<T> = VecDeque<T>;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: 4 warnings emitted

ソースコード

diff #

use std::io::Write;
use std::collections::*;

type Map<K, V> = BTreeMap<K, V>;
type Set<T> = BTreeSet<T>;
type Deque<T> = VecDeque<T>;

fn run() {
    input! {
        n: usize,
        q: usize,
        _x: [u32; 2],
        _a: [u32; n],
        ask: [(usize1, usize); q],
    }
    let batch = ((n as f64) / (q as f64).sqrt()).ceil() as usize;
    let mut p = (0..q).collect::<Vec<_>>();
    p.sort_by_key(|x| {
        let (l, r) = ask[*x];
        let l = l / batch;
        let r = if l % 2 == 0 {r} else {!r};
        (l, r)
    });
    use util::*;
    println!("{}", p.iter().map(|p| *p + 1).join(" "));
}

fn main() {
    run();
}

// ---------- begin input macro ----------
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[macro_export]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, bytes) => {
        read_value!($iter, String).bytes().collect::<Vec<u8>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// ---------- end input macro ----------
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