結果
問題 | No.1480 Many Complete Graphs |
ユーザー | akakimidori |
提出日時 | 2021-04-16 21:05:30 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 2,556 bytes |
コンパイル時間 | 19,023 ms |
コンパイル使用メモリ | 402,480 KB |
実行使用メモリ | 19,456 KB |
最終ジャッジ日時 | 2024-07-03 04:12:04 |
合計ジャッジ時間 | 17,038 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 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 | 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 | 2 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 15 ms
8,576 KB |
testcase_14 | AC | 10 ms
6,272 KB |
testcase_15 | AC | 25 ms
9,600 KB |
testcase_16 | AC | 16 ms
7,424 KB |
testcase_17 | AC | 14 ms
7,040 KB |
testcase_18 | AC | 5 ms
5,376 KB |
testcase_19 | AC | 15 ms
7,168 KB |
testcase_20 | AC | 21 ms
7,808 KB |
testcase_21 | AC | 14 ms
8,576 KB |
testcase_22 | AC | 8 ms
5,504 KB |
testcase_23 | AC | 29 ms
14,592 KB |
testcase_24 | AC | 23 ms
10,112 KB |
testcase_25 | AC | 45 ms
13,440 KB |
testcase_26 | AC | 57 ms
14,848 KB |
testcase_27 | AC | 25 ms
10,240 KB |
testcase_28 | AC | 37 ms
17,768 KB |
testcase_29 | AC | 37 ms
17,908 KB |
testcase_30 | AC | 37 ms
17,396 KB |
testcase_31 | AC | 37 ms
17,392 KB |
testcase_32 | AC | 37 ms
17,776 KB |
testcase_33 | AC | 35 ms
17,392 KB |
testcase_34 | AC | 36 ms
17,904 KB |
testcase_35 | AC | 35 ms
17,396 KB |
testcase_36 | AC | 35 ms
17,392 KB |
testcase_37 | AC | 35 ms
17,388 KB |
testcase_38 | AC | 34 ms
17,520 KB |
testcase_39 | AC | 35 ms
17,520 KB |
testcase_40 | AC | 36 ms
17,388 KB |
testcase_41 | AC | 35 ms
17,268 KB |
testcase_42 | AC | 37 ms
17,776 KB |
testcase_43 | AC | 35 ms
17,520 KB |
testcase_44 | AC | 36 ms
17,392 KB |
testcase_45 | AC | 37 ms
17,904 KB |
testcase_46 | AC | 36 ms
17,388 KB |
testcase_47 | AC | 79 ms
18,304 KB |
testcase_48 | AC | 79 ms
18,176 KB |
testcase_49 | AC | 79 ms
18,304 KB |
testcase_50 | AC | 45 ms
18,048 KB |
testcase_51 | AC | 82 ms
18,304 KB |
testcase_52 | AC | 54 ms
17,620 KB |
testcase_53 | AC | 54 ms
17,616 KB |
testcase_54 | AC | 54 ms
17,616 KB |
testcase_55 | AC | 53 ms
17,744 KB |
testcase_56 | AC | 55 ms
17,616 KB |
testcase_57 | AC | 33 ms
19,456 KB |
testcase_58 | AC | 38 ms
16,276 KB |
evil_aftercontest.txt | AC | 75 ms
30,120 KB |
コンパイルメッセージ
warning: unused variable: `out` --> src/main.rs:42:45 | 42 | fn run<W: Write>(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<W>) { | ^^^ help: if this is intentional, prefix it with an underscore: `_out` | = note: `#[warn(unused_variables)]` on by default
ソースコード
// ---------- begin scannner ---------- #[allow(dead_code)] mod scanner { use std::str::FromStr; pub struct Scanner<'a> { it: std::str::SplitWhitespace<'a>, } impl<'a> Scanner<'a> { pub fn new(s: &'a String) -> Scanner<'a> { Scanner { it: s.split_whitespace(), } } pub fn next<T: FromStr>(&mut self) -> T { self.it.next().unwrap().parse::<T>().ok().unwrap() } pub fn next_bytes(&mut self) -> Vec<u8> { self.it.next().unwrap().bytes().collect() } pub fn next_chars(&mut self) -> Vec<char> { self.it.next().unwrap().chars().collect() } pub fn next_vec<T: FromStr>(&mut self, len: usize) -> Vec<T> { (0..len).map(|_| self.next()).collect() } } } // ---------- end scannner ---------- use std::io::Write; fn main() { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut sc = scanner::Scanner::new(&s); let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); run(&mut sc, &mut out); } fn run<W: Write>(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<W>) { let n: usize = sc.next(); let m: usize = sc.next(); let mut g = vec![vec![]; n + 1]; for _ in 0..m { let k: usize = sc.next(); let c: u64 = sc.next(); let s: Vec<usize> = sc.next_vec(k); let zero = g.len(); g.push(vec![]); let one = g.len(); g.push(vec![]); for &s in s.iter() { let d = (s / 2) as u64; if s & 1 == 0 { g[s].push((zero, c + d)); g[zero].push((s, d)); g[one].push((s, d)); } else { g[s].push((one, c + d + 1)); g[zero].push((s, d + 1)); g[one].push((s, d)); } } } use std::cmp::Reverse; let inf = std::u64::MAX; let mut dp = vec![inf; g.len()]; dp[1] = 1; let mut h = std::collections::BinaryHeap::new(); h.push(Reverse((0, 1))); while let Some(Reverse((d, v))) = h.pop() { if d > dp[v] { continue; } for &(u, w) in g[v].iter() { let d = d + w; if d < dp[u] { dp[u] = d; h.push(Reverse((d, u))); } } } if dp[n] != inf { println!("{}", dp[n]); } else { println!("-1"); } }