Submission #53050792


Source Code Expand

Copy
// -*- coding:utf-8-unix -*-
use proconio::input;
fn distance(x: &Vec<i32>, y: &Vec<i32>) -> f32 {
let sum = x
.iter()
.zip(y.iter())
.map(|(x, y)| x.abs_diff(*y).pow(2))
.sum::<u32>() as f32;
sum.sqrt()
}
fn main() {
input! {
(n, d): (usize,usize),
x: [[i32; d]; n],
}
let result = x
.iter()
.enumerate()
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// -*- coding:utf-8-unix -*-

use proconio::input;

fn distance(x: &Vec<i32>, y: &Vec<i32>) -> f32 {
    let sum = x
        .iter()
        .zip(y.iter())
        .map(|(x, y)| x.abs_diff(*y).pow(2))
        .sum::<u32>() as f32;
    sum.sqrt()
}

fn main() {
    input! {
        (n, d): (usize,usize),
        x: [[i32; d]; n],
    }
    let result = x
        .iter()
        .enumerate()
        .flat_map(|(i, xi)| {
            let sub_x = x.iter().skip(i + 1);
            sub_x.map(move |xj| distance(&xi, &xj))
        })
        .filter(|&d| d.fract() == 0.0)
        .count();

    println!("{}", result);
}

Submission Info

Submission Time
Task B - Good Distance
User homura10059
Language Rust (rustc 1.70.0)
Score 200
Code Size 650 Byte
Status AC
Exec Time 1 ms
Memory 2512 KB

Judge Result

Set Name All Sample
Score / Max Score 200 / 200 0 / 0
Status
AC × 13
AC × 3
Set Name Test Cases
All sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 AC 1 ms 2368 KB
sample_02 AC 1 ms 2288 KB
sample_03 AC 1 ms 2308 KB
testcase_01 AC 1 ms 2512 KB
testcase_02 AC 1 ms 2304 KB
testcase_03 AC 1 ms 2308 KB
testcase_04 AC 1 ms 2508 KB
testcase_05 AC 1 ms 2368 KB
testcase_06 AC 0 ms 2364 KB
testcase_07 AC 1 ms 2344 KB
testcase_08 AC 1 ms 2328 KB
testcase_09 AC 1 ms 2412 KB
testcase_10 AC 1 ms 2504 KB


2025-04-04 (Fri)
04:59:03 +00:00