結果
問題 | No.1254 補強への架け橋 |
ユーザー | Strorkis |
提出日時 | 2020-10-10 12:10:50 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 118 ms / 2,000 ms |
コード長 | 2,376 bytes |
コンパイル時間 | 14,352 ms |
コンパイル使用メモリ | 377,532 KB |
実行使用メモリ | 30,208 KB |
最終ジャッジ日時 | 2024-07-20 15:54:34 |
合計ジャッジ時間 | 26,000 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | 1 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 1 ms
5,376 KB |
testcase_14 | AC | 1 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | AC | 1 ms
5,376 KB |
testcase_17 | AC | 1 ms
5,376 KB |
testcase_18 | AC | 1 ms
5,376 KB |
testcase_19 | AC | 1 ms
5,376 KB |
testcase_20 | AC | 1 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
testcase_23 | AC | 1 ms
5,376 KB |
testcase_24 | AC | 1 ms
5,376 KB |
testcase_25 | AC | 1 ms
5,376 KB |
testcase_26 | AC | 1 ms
5,376 KB |
testcase_27 | AC | 1 ms
5,376 KB |
testcase_28 | AC | 1 ms
5,376 KB |
testcase_29 | AC | 1 ms
5,376 KB |
testcase_30 | AC | 1 ms
5,376 KB |
testcase_31 | AC | 1 ms
5,376 KB |
testcase_32 | AC | 1 ms
5,376 KB |
testcase_33 | AC | 1 ms
5,376 KB |
testcase_34 | AC | 1 ms
5,376 KB |
testcase_35 | AC | 1 ms
5,376 KB |
testcase_36 | AC | 1 ms
5,376 KB |
testcase_37 | AC | 1 ms
5,376 KB |
testcase_38 | AC | 1 ms
5,376 KB |
testcase_39 | AC | 1 ms
5,376 KB |
testcase_40 | AC | 1 ms
5,376 KB |
testcase_41 | AC | 1 ms
5,376 KB |
testcase_42 | AC | 1 ms
5,376 KB |
testcase_43 | AC | 1 ms
5,376 KB |
testcase_44 | AC | 1 ms
5,376 KB |
testcase_45 | AC | 1 ms
5,376 KB |
testcase_46 | AC | 1 ms
5,376 KB |
testcase_47 | AC | 1 ms
5,376 KB |
testcase_48 | AC | 1 ms
5,376 KB |
testcase_49 | AC | 1 ms
5,376 KB |
testcase_50 | AC | 1 ms
5,376 KB |
testcase_51 | AC | 1 ms
5,376 KB |
testcase_52 | AC | 1 ms
5,376 KB |
testcase_53 | AC | 1 ms
5,376 KB |
testcase_54 | AC | 2 ms
5,376 KB |
testcase_55 | AC | 1 ms
5,376 KB |
testcase_56 | AC | 1 ms
5,376 KB |
testcase_57 | AC | 1 ms
5,376 KB |
testcase_58 | AC | 1 ms
5,376 KB |
testcase_59 | AC | 1 ms
5,376 KB |
testcase_60 | AC | 1 ms
5,376 KB |
testcase_61 | AC | 1 ms
5,376 KB |
testcase_62 | AC | 1 ms
5,376 KB |
testcase_63 | AC | 5 ms
5,376 KB |
testcase_64 | AC | 2 ms
5,376 KB |
testcase_65 | AC | 4 ms
5,376 KB |
testcase_66 | AC | 3 ms
5,376 KB |
testcase_67 | AC | 2 ms
5,376 KB |
testcase_68 | AC | 3 ms
5,376 KB |
testcase_69 | AC | 4 ms
5,376 KB |
testcase_70 | AC | 2 ms
5,376 KB |
testcase_71 | AC | 2 ms
5,376 KB |
testcase_72 | AC | 4 ms
5,376 KB |
testcase_73 | AC | 2 ms
5,376 KB |
testcase_74 | AC | 4 ms
5,376 KB |
testcase_75 | AC | 3 ms
5,376 KB |
testcase_76 | AC | 2 ms
5,376 KB |
testcase_77 | AC | 3 ms
5,376 KB |
testcase_78 | AC | 5 ms
5,376 KB |
testcase_79 | AC | 5 ms
5,376 KB |
testcase_80 | AC | 5 ms
5,376 KB |
testcase_81 | AC | 5 ms
5,376 KB |
testcase_82 | AC | 5 ms
5,376 KB |
testcase_83 | AC | 74 ms
14,208 KB |
testcase_84 | AC | 74 ms
13,952 KB |
testcase_85 | AC | 36 ms
9,344 KB |
testcase_86 | AC | 61 ms
12,288 KB |
testcase_87 | AC | 67 ms
13,312 KB |
testcase_88 | AC | 8 ms
5,376 KB |
testcase_89 | AC | 72 ms
14,336 KB |
testcase_90 | AC | 38 ms
9,856 KB |
testcase_91 | AC | 30 ms
8,192 KB |
testcase_92 | AC | 15 ms
5,504 KB |
testcase_93 | AC | 53 ms
11,776 KB |
testcase_94 | AC | 46 ms
10,880 KB |
testcase_95 | AC | 50 ms
10,880 KB |
testcase_96 | AC | 69 ms
13,568 KB |
testcase_97 | AC | 24 ms
7,296 KB |
testcase_98 | AC | 70 ms
13,568 KB |
testcase_99 | AC | 32 ms
9,216 KB |
testcase_100 | AC | 77 ms
14,336 KB |
testcase_101 | AC | 12 ms
5,376 KB |
testcase_102 | AC | 7 ms
5,376 KB |
testcase_103 | AC | 13 ms
5,376 KB |
testcase_104 | AC | 20 ms
6,528 KB |
testcase_105 | AC | 52 ms
11,776 KB |
testcase_106 | AC | 27 ms
7,808 KB |
testcase_107 | AC | 72 ms
14,080 KB |
testcase_108 | AC | 75 ms
13,824 KB |
testcase_109 | AC | 52 ms
11,648 KB |
testcase_110 | AC | 49 ms
10,752 KB |
testcase_111 | AC | 53 ms
11,392 KB |
testcase_112 | AC | 20 ms
6,272 KB |
testcase_113 | AC | 40 ms
10,496 KB |
testcase_114 | AC | 23 ms
7,680 KB |
testcase_115 | AC | 9 ms
5,376 KB |
testcase_116 | AC | 34 ms
8,448 KB |
testcase_117 | AC | 19 ms
6,272 KB |
testcase_118 | AC | 72 ms
13,568 KB |
testcase_119 | AC | 34 ms
9,088 KB |
testcase_120 | AC | 69 ms
13,056 KB |
testcase_121 | AC | 16 ms
5,632 KB |
testcase_122 | AC | 33 ms
8,320 KB |
testcase_123 | AC | 1 ms
5,376 KB |
testcase_124 | AC | 110 ms
30,208 KB |
testcase_125 | AC | 118 ms
30,208 KB |
ソースコード
fn read<T: std::str::FromStr>() -> T { let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); input.trim_end().parse().ok().unwrap() } macro_rules! read_to_tuple { ( $( $t:ty ),* ) => {{ let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); let mut iter = input.split_whitespace(); ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* ) }}; } fn vec_to_string<T: std::fmt::Display>(v: Vec<T>, s: &str) -> String { v.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(s) } use std::cmp::min; struct LowLink { g: Vec<Vec<(usize, usize)>>, used: Vec<bool>, ord: Vec<usize>, low: Vec<usize>, bridges: Vec<usize>, } impl LowLink { fn new(n: usize, g: Vec<Vec<(usize, usize)>>) -> LowLink { let mut low_link = LowLink { g, used: vec![false; n], ord: vec![0; n], low: vec![0; n], bridges: Vec::new(), }; let mut k = 0; for i in 0..n { if low_link.used[i] { continue; } low_link.dfs(i, !0, &mut k); } low_link } fn dfs(&mut self, from: usize, par: usize, k: &mut usize) { self.used[from] = true; self.ord[from] = *k; *k += 1; self.low[from] = self.ord[from]; for (to, i) in self.g[from].clone() { if !self.used[to] { self.dfs(to, from, k); self.low[from] = min(self.low[from], self.low[to]); if self.ord[from] < self.low[to] { self.bridges.push(i); } } else if to != par { self.low[from] = min(self.low[from], self.ord[to]); } } } } fn main() { let n = read::<usize>(); let mut g = vec![vec![]; n]; for i in 1..=n { let (from, to) = read_to_tuple!(usize, usize); let (from, to) = (from - 1, to - 1); g[from].push((to, i)); g[to].push((from, i)); } let low_link = LowLink::new(n, g); let mut is_bridge = vec![false; n + 1]; for bridge in low_link.bridges { is_bridge[bridge] = true; } let non_bridges = (1..=n).filter(|&i| !is_bridge[i]).collect::<Vec<_>>(); println!("{}", non_bridges.len()); println!("{}", vec_to_string(non_bridges, " ")); }