結果
問題 | No.1508 Avoid being hit |
ユーザー | koba-e964 |
提出日時 | 2021-12-25 01:34:55 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,546 bytes |
コンパイル時間 | 12,385 ms |
コンパイル使用メモリ | 382,336 KB |
実行使用メモリ | 9,856 KB |
最終ジャッジ日時 | 2024-09-20 00:59:02 |
合計ジャッジ時間 | 40,791 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,089 ms
7,808 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 0 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 | AC | 1 ms
5,376 KB |
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 | 0 ms
5,376 KB |
testcase_13 | AC | 1 ms
5,376 KB |
testcase_14 | AC | 1 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | AC | 901 ms
7,808 KB |
testcase_17 | AC | 526 ms
5,376 KB |
testcase_18 | AC | 388 ms
5,376 KB |
testcase_19 | AC | 799 ms
6,912 KB |
testcase_20 | AC | 1,070 ms
8,704 KB |
testcase_21 | AC | 695 ms
6,528 KB |
testcase_22 | AC | 897 ms
7,680 KB |
testcase_23 | AC | 947 ms
8,064 KB |
testcase_24 | AC | 1,542 ms
9,856 KB |
testcase_25 | AC | 1,376 ms
9,216 KB |
testcase_26 | AC | 95 ms
5,376 KB |
testcase_27 | AC | 700 ms
5,632 KB |
testcase_28 | AC | 713 ms
5,632 KB |
testcase_29 | AC | 1,417 ms
9,344 KB |
testcase_30 | AC | 764 ms
6,016 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 363 ms
5,376 KB |
testcase_34 | AC | 1,215 ms
7,808 KB |
testcase_35 | AC | 120 ms
5,376 KB |
testcase_36 | AC | 689 ms
5,376 KB |
testcase_37 | AC | 303 ms
5,376 KB |
testcase_38 | AC | 965 ms
6,656 KB |
testcase_39 | AC | 623 ms
5,376 KB |
testcase_40 | AC | 1,245 ms
7,936 KB |
testcase_41 | AC | 728 ms
5,504 KB |
testcase_42 | AC | 1,311 ms
8,192 KB |
testcase_43 | AC | 1,513 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 (l, r) = ch[0][0]; let mut vac = if r == n + 1 { l - 1 } else { r }; puts!("YES\n{}\n", vac); for i in 0..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); } }