結果
問題 | No.5011 Better Mo's Algorithm is Needed!! (Weighted) |
ユーザー | akakimidori |
提出日時 | 2022-12-17 00:09:46 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 134 ms / 5,000 ms |
コード長 | 2,639 bytes |
コンパイル時間 | 2,958 ms |
実行使用メモリ | 13,520 KB |
スコア | 34,917,031,721 |
最終ジャッジ日時 | 2022-12-17 00:10:56 |
合計ジャッジ時間 | 65,265 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge11 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
13,328 KB |
testcase_01 | AC | 127 ms
13,260 KB |
testcase_02 | AC | 128 ms
13,380 KB |
testcase_03 | AC | 127 ms
13,316 KB |
testcase_04 | AC | 129 ms
13,368 KB |
testcase_05 | AC | 125 ms
13,452 KB |
testcase_06 | AC | 127 ms
13,408 KB |
testcase_07 | AC | 126 ms
13,440 KB |
testcase_08 | AC | 127 ms
13,360 KB |
testcase_09 | AC | 127 ms
13,360 KB |
testcase_10 | AC | 128 ms
13,408 KB |
testcase_11 | AC | 131 ms
13,304 KB |
testcase_12 | AC | 131 ms
13,424 KB |
testcase_13 | AC | 129 ms
13,444 KB |
testcase_14 | AC | 125 ms
13,400 KB |
testcase_15 | AC | 128 ms
13,444 KB |
testcase_16 | AC | 126 ms
13,512 KB |
testcase_17 | AC | 129 ms
13,448 KB |
testcase_18 | AC | 128 ms
13,316 KB |
testcase_19 | AC | 129 ms
13,408 KB |
testcase_20 | AC | 128 ms
13,380 KB |
testcase_21 | AC | 127 ms
13,496 KB |
testcase_22 | AC | 129 ms
13,304 KB |
testcase_23 | AC | 126 ms
13,316 KB |
testcase_24 | AC | 128 ms
13,340 KB |
testcase_25 | AC | 127 ms
13,400 KB |
testcase_26 | AC | 127 ms
13,500 KB |
testcase_27 | AC | 129 ms
13,320 KB |
testcase_28 | AC | 126 ms
13,300 KB |
testcase_29 | AC | 131 ms
13,444 KB |
testcase_30 | AC | 127 ms
13,440 KB |
testcase_31 | AC | 127 ms
13,336 KB |
testcase_32 | AC | 127 ms
13,304 KB |
testcase_33 | AC | 127 ms
13,264 KB |
testcase_34 | AC | 128 ms
13,392 KB |
testcase_35 | AC | 128 ms
13,280 KB |
testcase_36 | AC | 128 ms
13,476 KB |
testcase_37 | AC | 126 ms
13,440 KB |
testcase_38 | AC | 128 ms
13,324 KB |
testcase_39 | AC | 126 ms
13,392 KB |
testcase_40 | AC | 124 ms
13,360 KB |
testcase_41 | AC | 126 ms
13,416 KB |
testcase_42 | AC | 126 ms
13,328 KB |
testcase_43 | AC | 131 ms
13,408 KB |
testcase_44 | AC | 125 ms
13,400 KB |
testcase_45 | AC | 132 ms
13,260 KB |
testcase_46 | AC | 128 ms
13,336 KB |
testcase_47 | AC | 128 ms
13,416 KB |
testcase_48 | AC | 125 ms
13,440 KB |
testcase_49 | AC | 125 ms
13,368 KB |
testcase_50 | AC | 127 ms
13,444 KB |
testcase_51 | AC | 126 ms
13,416 KB |
testcase_52 | AC | 126 ms
13,328 KB |
testcase_53 | AC | 128 ms
13,488 KB |
testcase_54 | AC | 123 ms
13,252 KB |
testcase_55 | AC | 129 ms
13,320 KB |
testcase_56 | AC | 123 ms
13,364 KB |
testcase_57 | AC | 129 ms
13,392 KB |
testcase_58 | AC | 128 ms
13,296 KB |
testcase_59 | AC | 126 ms
13,408 KB |
testcase_60 | AC | 122 ms
13,416 KB |
testcase_61 | AC | 124 ms
13,492 KB |
testcase_62 | AC | 126 ms
13,304 KB |
testcase_63 | AC | 126 ms
13,372 KB |
testcase_64 | AC | 127 ms
13,296 KB |
testcase_65 | AC | 128 ms
13,328 KB |
testcase_66 | AC | 126 ms
13,472 KB |
testcase_67 | AC | 127 ms
13,364 KB |
testcase_68 | AC | 128 ms
13,420 KB |
testcase_69 | AC | 127 ms
13,324 KB |
testcase_70 | AC | 127 ms
13,372 KB |
testcase_71 | AC | 125 ms
13,348 KB |
testcase_72 | AC | 129 ms
13,480 KB |
testcase_73 | AC | 128 ms
13,344 KB |
testcase_74 | AC | 127 ms
13,328 KB |
testcase_75 | AC | 126 ms
13,404 KB |
testcase_76 | AC | 126 ms
13,364 KB |
testcase_77 | AC | 128 ms
13,508 KB |
testcase_78 | AC | 123 ms
13,428 KB |
testcase_79 | AC | 126 ms
13,324 KB |
testcase_80 | AC | 126 ms
13,432 KB |
testcase_81 | AC | 125 ms
13,420 KB |
testcase_82 | AC | 128 ms
13,416 KB |
testcase_83 | AC | 123 ms
13,412 KB |
testcase_84 | AC | 128 ms
13,308 KB |
testcase_85 | AC | 129 ms
13,520 KB |
testcase_86 | AC | 125 ms
13,428 KB |
testcase_87 | AC | 127 ms
13,444 KB |
testcase_88 | AC | 126 ms
13,328 KB |
testcase_89 | AC | 123 ms
13,376 KB |
testcase_90 | AC | 127 ms
13,332 KB |
testcase_91 | AC | 129 ms
13,256 KB |
testcase_92 | AC | 129 ms
13,420 KB |
testcase_93 | AC | 132 ms
13,320 KB |
testcase_94 | AC | 134 ms
13,376 KB |
testcase_95 | AC | 126 ms
13,408 KB |
testcase_96 | AC | 128 ms
13,372 KB |
testcase_97 | AC | 125 ms
13,360 KB |
testcase_98 | AC | 127 ms
13,300 KB |
testcase_99 | AC | 127 ms
13,344 KB |
testcase_100 | AC | 126 ms
13,324 KB |
testcase_101 | AC | 126 ms
13,416 KB |
testcase_102 | AC | 128 ms
13,332 KB |
testcase_103 | AC | 129 ms
13,416 KB |
testcase_104 | AC | 127 ms
13,300 KB |
testcase_105 | AC | 126 ms
13,296 KB |
testcase_106 | AC | 129 ms
13,440 KB |
testcase_107 | AC | 127 ms
13,352 KB |
testcase_108 | AC | 131 ms
13,432 KB |
testcase_109 | AC | 125 ms
13,300 KB |
testcase_110 | AC | 127 ms
13,412 KB |
testcase_111 | AC | 126 ms
13,256 KB |
testcase_112 | AC | 127 ms
13,408 KB |
testcase_113 | AC | 129 ms
13,360 KB |
testcase_114 | AC | 126 ms
13,368 KB |
testcase_115 | AC | 126 ms
13,420 KB |
testcase_116 | AC | 129 ms
13,420 KB |
testcase_117 | AC | 126 ms
13,424 KB |
testcase_118 | AC | 122 ms
13,416 KB |
testcase_119 | AC | 127 ms
13,420 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
ソースコード
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 } } }