Submission #68473579
Source Code Expand
use std::collections::BTreeMap;
use ordered_float::OrderedFloat;
use proconio::input;
fn main() {
input! {
n: usize,
xy: [(f64, f64); n],
}
let mut map_c = BTreeMap::new();
let mut map_d = BTreeMap::new();
for i in 0..n {
let (xi, yi) = xy[i];
for j in 0..n {
let (xj, yj) = xy[j];
let dx = xi - xj;
let dy = yi - yj;
if !(dx > 0.0 || (dx == 0.0 && dy > 0.0)) {
continue;
}
let s = OrderedFloat::from(dy / dx);
*map_c.entry(s).or_insert(0_u64) += 1;
let mx = OrderedFloat::from(0.5 * (xi + xj));
let my = OrderedFloat::from(0.5 * (yi + yj));
*map_d.entry((mx, my)).or_insert(0_u64) += 1;
}
}
let add: u64 = map_c.values().map(|&v| v * (v - 1) / 2).sum();
let sub: u64 = map_d.values().map(|&v| v * (v - 1) / 2).sum();
let res = add - sub;
println!("{res}");
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Trapezium |
| User | rsk0315 |
| Language | Rust (rustc 1.70.0) |
| Score | 475 |
| Code Size | 1015 Byte |
| Status | AC |
| Exec Time | 2351 ms |
| Memory | 137892 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 475 / 475 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-01.txt | AC | 1 ms | 1972 KiB |
| 00-sample-02.txt | AC | 1 ms | 1900 KiB |
| 01-01.txt | AC | 1 ms | 1896 KiB |
| 01-02.txt | AC | 34 ms | 7288 KiB |
| 01-03.txt | AC | 1849 ms | 111996 KiB |
| 01-04.txt | AC | 766 ms | 58992 KiB |
| 01-05.txt | AC | 2150 ms | 136896 KiB |
| 01-06.txt | AC | 2351 ms | 136748 KiB |
| 01-07.txt | AC | 1263 ms | 79908 KiB |
| 01-08.txt | AC | 1287 ms | 80452 KiB |
| 01-09.txt | AC | 1269 ms | 77680 KiB |
| 01-10.txt | AC | 871 ms | 60452 KiB |
| 01-11.txt | AC | 755 ms | 53176 KiB |
| 01-12.txt | AC | 1689 ms | 127616 KiB |
| 01-13.txt | AC | 1635 ms | 130544 KiB |
| 01-14.txt | AC | 2082 ms | 108444 KiB |
| 01-15.txt | AC | 1809 ms | 109700 KiB |
| 01-16.txt | AC | 2028 ms | 136788 KiB |
| 01-17.txt | AC | 1920 ms | 137892 KiB |
| 01-18.txt | AC | 1638 ms | 103488 KiB |
| 01-19.txt | AC | 1653 ms | 103492 KiB |
| 01-20.txt | AC | 1706 ms | 103576 KiB |
| 01-21.txt | AC | 2159 ms | 103160 KiB |
| 01-22.txt | AC | 2121 ms | 137448 KiB |
| 01-23.txt | AC | 1968 ms | 122120 KiB |
| 01-24.txt | AC | 2276 ms | 137684 KiB |
| 01-25.txt | AC | 2150 ms | 130772 KiB |
| 01-26.txt | AC | 2173 ms | 137544 KiB |