結果
問題 | No.1607 Kth Maximum Card |
ユーザー | akakimidori |
提出日時 | 2021-07-16 21:54:12 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,132 bytes |
コンパイル時間 | 12,728 ms |
コンパイル使用メモリ | 378,272 KB |
実行使用メモリ | 31,616 KB |
最終ジャッジ日時 | 2024-07-06 09:00:43 |
合計ジャッジ時間 | 24,307 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 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 | 0 ms
5,376 KB |
testcase_06 | AC | 0 ms
5,376 KB |
testcase_07 | WA | - |
testcase_08 | AC | 819 ms
31,444 KB |
testcase_09 | AC | 625 ms
26,080 KB |
testcase_10 | AC | 888 ms
31,616 KB |
testcase_11 | AC | 117 ms
8,704 KB |
testcase_12 | AC | 614 ms
25,224 KB |
testcase_13 | AC | 74 ms
6,144 KB |
testcase_14 | AC | 91 ms
7,588 KB |
testcase_15 | AC | 494 ms
24,192 KB |
testcase_16 | AC | 70 ms
6,620 KB |
testcase_17 | AC | 22 ms
5,376 KB |
testcase_18 | AC | 275 ms
17,092 KB |
testcase_19 | AC | 153 ms
11,264 KB |
testcase_20 | AC | 224 ms
13,748 KB |
testcase_21 | AC | 250 ms
14,996 KB |
testcase_22 | AC | 829 ms
31,296 KB |
testcase_23 | AC | 909 ms
31,400 KB |
testcase_24 | AC | 217 ms
11,576 KB |
testcase_25 | AC | 124 ms
7,908 KB |
testcase_26 | AC | 157 ms
9,040 KB |
testcase_27 | AC | 226 ms
11,792 KB |
testcase_28 | AC | 180 ms
10,052 KB |
testcase_29 | AC | 456 ms
19,472 KB |
testcase_30 | AC | 1,100 ms
30,856 KB |
testcase_31 | AC | 431 ms
17,692 KB |
testcase_32 | AC | 197 ms
20,320 KB |
testcase_33 | AC | 215 ms
20,256 KB |
testcase_34 | AC | 172 ms
20,204 KB |
testcase_35 | AC | 172 ms
20,280 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![k + 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(); }