結果
問題 | No.2080 Simple Nim Query |
ユーザー | akakimidori |
提出日時 | 2022-09-25 21:15:12 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 287 ms / 3,000 ms |
コード長 | 2,454 bytes |
コンパイル時間 | 11,710 ms |
コンパイル使用メモリ | 390,556 KB |
実行使用メモリ | 15,104 KB |
最終ジャッジ日時 | 2024-06-12 07:21:26 |
合計ジャッジ時間 | 14,978 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 0 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,812 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 197 ms
6,940 KB |
testcase_04 | AC | 200 ms
6,980 KB |
testcase_05 | AC | 287 ms
15,104 KB |
testcase_06 | AC | 240 ms
10,108 KB |
testcase_07 | AC | 242 ms
10,048 KB |
testcase_08 | AC | 274 ms
12,160 KB |
testcase_09 | AC | 265 ms
12,148 KB |
testcase_10 | AC | 239 ms
8,360 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: unused variable: `out` --> src/main.rs:23:13 | 23 | let mut out = std::io::BufWriter::new(out.lock()); | ^^^ help: if this is intentional, prefix it with an underscore: `_out` | = note: `#[warn(unused_variables)]` on by default warning: variable does not need to be mutable --> src/main.rs:23:9 | 23 | let mut out = std::io::BufWriter::new(out.lock()); | ----^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` 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 `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 run() { input! { n: usize, q: usize, a: [u32; n], ask: [(u8, usize1, u32); q], } let mut set = Set::new(); let mut a = a; for (i, a) in a.iter().enumerate() { if *a > 1 { set.insert(i); } } let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); for (op, x, y) in ask { if op == 1 { set.remove(&x); a[x] = y; if y > 1 { set.insert(x); } } else { let y = y as usize; let win = if let Some(&p) = set.range(x..y).next_back() { (y - p - 1) % 2 == 0 } else { (y - x) % 2 == 1 }; println!("{}", if win {"F"} else {"S"}); } } } 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 ----------