結果
問題 | No.2687 所により大雨 |
ユーザー | akakimidori |
提出日時 | 2024-03-20 21:49:56 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 109 ms / 2,000 ms |
コード長 | 6,179 bytes |
コンパイル時間 | 15,505 ms |
コンパイル使用メモリ | 391,512 KB |
実行使用メモリ | 6,144 KB |
最終ジャッジ日時 | 2024-09-30 07:38:24 |
合計ジャッジ時間 | 18,264 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
6,144 KB |
testcase_01 | AC | 28 ms
6,016 KB |
testcase_02 | AC | 29 ms
6,016 KB |
testcase_03 | AC | 29 ms
6,144 KB |
testcase_04 | AC | 29 ms
6,016 KB |
testcase_05 | AC | 1 ms
5,248 KB |
testcase_06 | AC | 1 ms
5,248 KB |
testcase_07 | AC | 1 ms
5,248 KB |
testcase_08 | AC | 1 ms
5,248 KB |
testcase_09 | AC | 1 ms
5,248 KB |
testcase_10 | AC | 109 ms
5,376 KB |
testcase_11 | AC | 108 ms
5,376 KB |
testcase_12 | AC | 106 ms
5,504 KB |
testcase_13 | AC | 107 ms
5,632 KB |
testcase_14 | AC | 103 ms
5,504 KB |
testcase_15 | AC | 102 ms
5,632 KB |
testcase_16 | AC | 106 ms
5,504 KB |
testcase_17 | AC | 106 ms
5,504 KB |
testcase_18 | AC | 103 ms
5,504 KB |
testcase_19 | AC | 107 ms
5,504 KB |
testcase_20 | AC | 1 ms
5,248 KB |
testcase_21 | AC | 1 ms
5,248 KB |
testcase_22 | AC | 1 ms
5,248 KB |
testcase_23 | AC | 1 ms
5,248 KB |
testcase_24 | AC | 2 ms
5,248 KB |
testcase_25 | AC | 2 ms
5,248 KB |
testcase_26 | AC | 2 ms
5,248 KB |
testcase_27 | AC | 2 ms
5,248 KB |
testcase_28 | AC | 2 ms
5,248 KB |
コンパイルメッセージ
warning: unused import: `std::io::Write` --> src/main.rs:1:5 | 1 | use std::io::Write; | ^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: type alias `Map` is never used --> src/main.rs:4:6 | 4 | type Map<K, V> = BTreeMap<K, V>; | ^^^ | = note: `#[warn(dead_code)]` on by default warning: type alias `Set` is never used --> src/main.rs:5:6 | 5 | type Set<T> = BTreeSet<T>; | ^^^ warning: type alias `Deque` is never used --> src/main.rs:6:6 | 6 | type Deque<T> = VecDeque<T>; | ^^^^^
ソースコード
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 main() { input! { n: usize, m: usize, a: [(i64, i64); n], b: [(i64, i64); m], k: usize, p: [i64; k], } let mut a = a; a.sort(); a.dedup_by(|a, b| { b.1 >= a.0 && { b.1 = a.1.max(b.1); true } }); let mut b = b; b.sort(); b.dedup_by(|a, b| { b.1 >= a.0 && { b.1 = a.1.max(b.1); true } }); if a.len() < n || b.len() < m { println!("{}", (0..k).map(|_| 1).join(" ")); return; } let mut ans = vec![]; for p in p { let mut res = 0; for &(l, r) in b.iter() { let s = l - p; let t = r - p; let pos = a.lower_bound_by_key(&(p - t), |p| p.0); if pos < a.len() && a[pos].0 <= p - s { res = 1; } if pos > 0 && a[pos - 1].1 >= p - t { res = 1; } } ans.push(res); } use util::*; println!("{}", ans.iter().join(" ")); } // ---------- 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 ---------- // ---------- begin super slice ---------- pub trait SuperSlice { type Item; fn lower_bound(&self, key: &Self::Item) -> usize where Self::Item: Ord; fn lower_bound_by<F>(&self, f: F) -> usize where F: FnMut(&Self::Item) -> std::cmp::Ordering; fn lower_bound_by_key<K, F>(&self, key: &K, f: F) -> usize where K: Ord, F: FnMut(&Self::Item) -> K; fn upper_bound(&self, key: &Self::Item) -> usize where Self::Item: Ord; fn upper_bound_by<F>(&self, f: F) -> usize where F: FnMut(&Self::Item) -> std::cmp::Ordering; fn upper_bound_by_key<K, F>(&self, key: &K, f: F) -> usize where K: Ord, F: FnMut(&Self::Item) -> K; fn next_permutation(&mut self) -> bool where Self::Item: Ord; fn next_permutation_by<F>(&mut self, f: F) -> bool where F: FnMut(&Self::Item, &Self::Item) -> std::cmp::Ordering; fn prev_permutation(&mut self) -> bool where Self::Item: Ord; } impl<T> SuperSlice for [T] { type Item = T; fn lower_bound(&self, key: &Self::Item) -> usize where T: Ord, { self.lower_bound_by(|p| p.cmp(key)) } fn lower_bound_by<F>(&self, mut f: F) -> usize where F: FnMut(&Self::Item) -> std::cmp::Ordering, { self.binary_search_by(|p| f(p).then(std::cmp::Ordering::Greater)) .unwrap_err() } fn lower_bound_by_key<K, F>(&self, key: &K, mut f: F) -> usize where K: Ord, F: FnMut(&Self::Item) -> K, { self.lower_bound_by(|p| f(p).cmp(key)) } fn upper_bound(&self, key: &Self::Item) -> usize where T: Ord, { self.upper_bound_by(|p| p.cmp(key)) } fn upper_bound_by<F>(&self, mut f: F) -> usize where F: FnMut(&Self::Item) -> std::cmp::Ordering, { self.binary_search_by(|p| f(p).then(std::cmp::Ordering::Less)) .unwrap_err() } fn upper_bound_by_key<K, F>(&self, key: &K, mut f: F) -> usize where K: Ord, F: FnMut(&Self::Item) -> K, { self.upper_bound_by(|p| f(p).cmp(key)) } fn next_permutation(&mut self) -> bool where T: Ord, { self.next_permutation_by(|a, b| a.cmp(b)) } fn next_permutation_by<F>(&mut self, mut f: F) -> bool where F: FnMut(&Self::Item, &Self::Item) -> std::cmp::Ordering, { use std::cmp::Ordering::*; if let Some(x) = self.windows(2).rposition(|a| f(&a[0], &a[1]) == Less) { let y = self.iter().rposition(|b| f(&self[x], b) == Less).unwrap(); self.swap(x, y); self[(x + 1)..].reverse(); true } else { self.reverse(); false } } fn prev_permutation(&mut self) -> bool where T: Ord, { self.next_permutation_by(|a, b| a.cmp(b).reverse()) } } // ---------- end super slice ---------- 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 } } }