結果
問題 | No.1508 Avoid being hit |
ユーザー | koba-e964 |
提出日時 | 2021-12-25 01:27:30 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,480 bytes |
コンパイル時間 | 14,522 ms |
コンパイル使用メモリ | 376,816 KB |
実行使用メモリ | 9,844 KB |
最終ジャッジ日時 | 2024-09-20 00:50:19 |
合計ジャッジ時間 | 46,048 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,171 ms
7,808 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | WA | - |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 1 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | AC | 1,032 ms
7,808 KB |
testcase_17 | AC | 599 ms
5,376 KB |
testcase_18 | AC | 433 ms
5,376 KB |
testcase_19 | AC | 884 ms
6,784 KB |
testcase_20 | AC | 1,195 ms
8,704 KB |
testcase_21 | AC | 791 ms
6,528 KB |
testcase_22 | AC | 996 ms
7,552 KB |
testcase_23 | AC | 1,085 ms
8,064 KB |
testcase_24 | AC | 1,710 ms
9,844 KB |
testcase_25 | AC | 1,558 ms
9,216 KB |
testcase_26 | AC | 108 ms
5,376 KB |
testcase_27 | AC | 797 ms
5,632 KB |
testcase_28 | AC | 796 ms
5,632 KB |
testcase_29 | AC | 1,602 ms
9,344 KB |
testcase_30 | AC | 855 ms
6,016 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 416 ms
5,376 KB |
testcase_34 | AC | 1,361 ms
7,808 KB |
testcase_35 | AC | 135 ms
5,376 KB |
testcase_36 | AC | 756 ms
5,376 KB |
testcase_37 | AC | 333 ms
5,376 KB |
testcase_38 | AC | 1,093 ms
6,656 KB |
testcase_39 | AC | 702 ms
5,376 KB |
testcase_40 | AC | 1,419 ms
8,192 KB |
testcase_41 | AC | 798 ms
5,504 KB |
testcase_42 | AC | 1,433 ms
8,064 KB |
testcase_43 | AC | 1,672 ms
9,088 KB |
testcase_44 | AC | 1 ms
5,376 KB |
testcase_45 | AC | 1 ms
5,376 KB |
ソースコード
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::{Write, BufWriter}; // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } macro_rules! input_inner { ($next:expr) => {}; ($next:expr,) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ($(read_value!($next, $t)),*) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => (read_value!($next, usize) - 1); ($next:expr, [ $t:tt ]) => {{ let len = read_value!($next, usize); read_value!($next, [$t; len]) }}; ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error")); } trait Change { fn chmax(&mut self, x: Self); fn chmin(&mut self, x: Self); } impl<T: PartialOrd> Change for T { fn chmax(&mut self, x: T) { if *self < x { *self = x; } } fn chmin(&mut self, x: T) { if *self > x { *self = x; } } } fn main() { let out = std::io::stdout(); let mut out = BufWriter::new(out.lock()); macro_rules! puts {($($format:tt)*) => (let _ = write!(out,$($format)*););} input! { n: usize, q: usize, a: [usize; q], b: [usize; q], } let mut v = vec![]; let mut ch = vec![vec![]; q]; for i in (0..q).rev() { v.push((a[i], a[i] + 1)); v.push((b[i], b[i] + 1)); v.sort(); let mut nv = vec![]; let mut st = 0; let mut last = 0; for &(l, r) in &v { if last < l { if last > 0 { nv.push((st, last)); } st = l; last = r; } else { last = r; } } nv.push((st, last)); v.clear(); for &(l, r) in &nv { if l == 1 && r == n + 1 { v.push((1, n + 1)); } else if l == 1 { if r - 1 > 1 { v.push((1, r - 1)); } } else if r == n + 1 { if l < n { v.push((l + 1, n + 1)); } } else { if l + 1 < r - 1 { v.push((l + 1, r - 1)); } } } ch[i] = nv.clone(); eprintln!("{} => {:?}", i, nv); } if v == [(1, n + 1)] { puts!("NO\n"); return; } let mut vac = ch[0][0].1; puts!("YES\n{}\n{}\n", vac, vac); for i in 1..q { let mut ok = 0; for j in max(1, vac - 1)..min(n, vac + 1) + 1 { if ch[i].iter().all(|&(l, r)| j < l || r <= j) { ok = j; break; } } vac = ok; puts!("{}\n", vac); } }