Skip to content

Commit

Permalink
diverta2019-2 b
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Feb 18, 2023
1 parent 805abfe commit 2f0aa0b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions diverta2019-2/src/bin/b.rs
@@ -1,24 +1,24 @@
use std::collections::HashMap;

use proconio::input;

fn main() {
input! {
n: usize,
xy: [(i64, i64); n],
};
let mut map = std::collections::BTreeMap::new();
for (i, &(x_i, y_i)) in xy.iter().enumerate() {
for (j, &(x_j, y_j)) in xy.iter().enumerate() {
if i == j {
continue;

let mut map = HashMap::new();
for (x1, y1) in xy.iter().copied() {
for (x2, y2) in xy.iter().copied() {
let p = x1 - x2;
let q = y1 - y2;
if p != 0 || q != 0 {
*map.entry((p, q)).or_insert(0_usize) += 1;
}
*map.entry((x_j - x_i, y_j - y_i)).or_insert(0) += 1;
}
}
let mut c = vec![];
for (&k, &v) in map.iter() {
c.push((v, k.0, k.1));
}
c.sort_by_key(|(c, _, _)| -c);
let ans = n as i64 - c.first().unwrap_or(&(0, 0, 0)).0;
println!("{:?}", ans);

let ans = n - *map.values().max().unwrap_or(&0);
println!("{}", ans);
}

0 comments on commit 2f0aa0b

Please sign in to comment.