#[allow(unused_imports)] use proconio::{ input, fastout, marker::{Bytes, Chars, Usize1}, }; fn main() { input!{ n: usize, _m: usize, k: i32, ed: [(Usize1, Usize1); _m] } let mut d = vec![vec![k+1; n]; n]; for i in 0..n { d[i][i] = 0; } for &(u, v) in &ed { d[u][v] = 1; d[v][u] = 1; } for v in 0..n { for u in 0..n { for w in 0..n { d[u][w] = std::cmp::min(d[u][w], d[u][v] + d[v][w]); } } } let mut vis = Vec::new(); for i in (1..n).rev() { vis.push(i); let m = vis.len(); let mut dp = vec![vec![k+1; m]; 1< k { continue; } for jj in 0..m { if bit & (1 << jj) == 0 { dp[bit | 1 << jj][jj] = std::cmp::min( dp[bit | 1 << jj][jj], dp[bit][j] + d[vis[j]][vis[jj]] ); } } } } let goal = (1 << m) - 1; if (0..m).all(|j| dp[goal][j] > k) { vis.pop(); } } println!("{}", vis.iter().map(|i| (1i64 << i) - 1).sum::()); }