use std::{collections::BinaryHeap, cmp::Reverse}; fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let ballons = (0..n).map(|_| { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp: Vec = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); (temp[0], temp[1]) }) .collect::>(); let mut pque = BinaryHeap::new(); for i in 0..n { let (lx, ly) = ballons[i]; for j in i+1..n { let (rx, ry) = ballons[j]; let dist = ((lx-rx)*(lx-rx) + (ly-ry)*(ly-ry)); pque.push((Reverse(dist), i, j)); } } let mut bombed = vec![false; n]; let mut result = 0usize; while let Some((_, i, j)) = pque.pop() { if bombed[i] || bombed[j] { continue; } if i == 0 { bombed[j] = true; result += 1; } else { bombed[i] = true; bombed[j] = true; } } println!("{}", result); }