結果
問題 |
No.3116 More and more teleporter
|
ユーザー |
|
提出日時 | 2025-04-19 15:54:33 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,944 bytes |
コンパイル時間 | 13,758 ms |
コンパイル使用メモリ | 404,412 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-04-19 15:54:49 |
合計ジャッジ時間 | 15,004 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 WA * 12 |
コンパイルメッセージ
warning: constant `DIRS` is never used --> src/main.rs:5:7 | 5 | const DIRS: [(isize, isize); 4] = [(0, 1), (1, 0), (0, -1), (-1, 0)]; | ^^^^ | = note: `#[warn(dead_code)]` on by default warning: trait `OrdExt` is never used --> src/main.rs:7:7 | 7 | trait OrdExt { | ^^^^^^ warning: variable `_N` should have a snake case name --> src/main.rs:35:9 | 35 | _N: usize, | ^^ help: convert the identifier to snake case: `_n` | = note: `#[warn(non_snake_case)]` on by default warning: variable `Q` should have a snake case name --> src/main.rs:36:9 | 36 | Q: usize, | ^ help: convert the identifier to snake case: `q` warning: variable `T` should have a snake case name --> src/main.rs:43:13 | 43 | T: usize, | ^ help: convert the identifier to snake case: `t`
ソースコード
use std::{cmp::min, collections::BTreeMap}; use proconio::{fastout, input, marker::Usize1}; const DIRS: [(isize, isize); 4] = [(0, 1), (1, 0), (0, -1), (-1, 0)]; trait OrdExt { fn chmax(&mut self, other: Self) -> bool; fn chmin(&mut self, other: Self) -> bool; } impl<T: Ord> OrdExt for T { fn chmax(&mut self, other: Self) -> bool { if *self < other { *self = other; true } else { false } } fn chmin(&mut self, other: Self) -> bool { if *self > other { *self = other; true } else { false } } } #[fastout] fn main() { input! { _N: usize, Q: usize, } let mut map = BTreeMap::from([(0, 0)]); for _ in 0..Q { input! { T: usize, } if T == 1 { input! { x: Usize1, } let left = map.range(..x).next_back(); let right = map.range(x..).next(); match (left, right) { (Some((&l, &cl)), Some((&r, &cr))) => { println!("{}", min(cl + x - l, cr + r - x)); } (Some((&l, &cl)), None) => { println!("{}", cl + x - l); } (None, Some((&r, &cr))) => { println!("{}", cr + r - x); } (None, None) => unreachable!(), } } else { input! { x: Usize1, c: usize, } let mut isok = true; if let Some((&l, &cl)) = map.range(..x).next_back() { isok &= c < cl + x - l; } if let Some((&r, &cr)) = map.range(x..).next() { isok &= c < cr + r - x; } if isok { map.insert(x, c); } } } }