結果
問題 | No.1607 Kth Maximum Card |
ユーザー | akakimidori |
提出日時 | 2021-07-16 21:53:28 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,132 bytes |
コンパイル時間 | 13,097 ms |
コンパイル使用メモリ | 404,228 KB |
実行使用メモリ | 31,672 KB |
最終ジャッジ日時 | 2024-07-06 08:59:25 |
合計ジャッジ時間 | 31,756 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | WA | - |
testcase_08 | AC | 1,723 ms
31,500 KB |
testcase_09 | AC | 1,213 ms
26,072 KB |
testcase_10 | AC | 1,627 ms
31,672 KB |
testcase_11 | AC | 131 ms
8,832 KB |
testcase_12 | AC | 1,031 ms
25,372 KB |
testcase_13 | AC | 83 ms
6,944 KB |
testcase_14 | AC | 104 ms
7,584 KB |
testcase_15 | AC | 819 ms
24,064 KB |
testcase_16 | AC | 71 ms
6,944 KB |
testcase_17 | AC | 26 ms
6,940 KB |
testcase_18 | WA | - |
testcase_19 | AC | 185 ms
11,264 KB |
testcase_20 | AC | 282 ms
13,752 KB |
testcase_21 | AC | 300 ms
14,864 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 241 ms
11,572 KB |
testcase_25 | AC | 133 ms
8,040 KB |
testcase_26 | AC | 169 ms
9,168 KB |
testcase_27 | AC | 264 ms
11,704 KB |
testcase_28 | AC | 204 ms
10,048 KB |
testcase_29 | AC | 560 ms
19,468 KB |
testcase_30 | AC | 2,085 ms
30,856 KB |
testcase_31 | AC | 618 ms
17,696 KB |
testcase_32 | AC | 249 ms
20,192 KB |
testcase_33 | AC | 231 ms
20,252 KB |
testcase_34 | AC | 233 ms
20,200 KB |
testcase_35 | AC | 231 ms
20,400 KB |
コンパイルメッセージ
warning: unused import: `std::io::Write` --> src/main.rs:72:5 | 72 | use std::io::Write; | ^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: type alias `Map` is never used --> src/main.rs:75:6 | 75 | type Map<K, V> = BTreeMap<K, V>; | ^^^ | = note: `#[warn(dead_code)]` on by default warning: type alias `Set` is never used --> src/main.rs:76:6 | 76 | type Set<T> = BTreeSet<T>; | ^^^
ソースコード
// ---------- begin chmin, chmax ---------- pub trait ChangeMinMax { fn chmin(&mut self, x: Self) -> bool; fn chmax(&mut self, x: Self) -> bool; } impl<T: PartialOrd> ChangeMinMax for T { fn chmin(&mut self, x: Self) -> bool { *self > x && { *self = x; true } } fn chmax(&mut self, x: Self) -> bool { *self < x && { *self = x; true } } } // ---------- end chmin, chmax ---------- // ---------- begin input macro ---------- // reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 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_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_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 ---------- 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, m: usize, k: u32, e: [(usize1, usize1, u32); m], } let valid = |m: u32| -> bool { let mut g = vec![vec![]; n]; for &(a, b, c) in e.iter() { let c = if c >= m {1} else {0}; g[a].push((b, c)); g[b].push((a, c)); } let mut dp = vec![m + 1; n]; dp[0] = 0; let mut deq = Deque::new(); deq.push_back(0); while let Some(v) = deq.pop_front() { let d = dp[v]; for &(u, c) in g[v].iter() { if c == 0 && dp[u].chmin(d) { deq.push_front(u); } if c == 1 && dp[u].chmin(d + 1) { deq.push_back(u); } } } dp[n - 1] < k }; let mut ng = 0; let mut ok = 200000; while ok - ng > 1 { let mid = (ok + ng) / 2; if valid(mid) { ok = mid; } else { ng = mid; } } println!("{}", ng); } fn main() { run(); }