結果

問題 No.1265 Balloon Survival
ユーザー Moss_LocalMoss_Local
提出日時 2020-10-24 06:19:40
言語 Rust
(1.77.0 + proconio)
結果
WA  
実行時間 -
コード長 4,688 bytes
コンパイル時間 12,911 ms
コンパイル使用メモリ 402,104 KB
実行使用メモリ 19,216 KB
最終ジャッジ日時 2024-07-21 14:54:56
合計ジャッジ時間 15,146 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,812 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 9 ms
6,944 KB
testcase_15 AC 7 ms
6,940 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 AC 40 ms
10,624 KB
testcase_18 AC 4 ms
6,944 KB
testcase_19 AC 4 ms
6,940 KB
testcase_20 AC 9 ms
6,944 KB
testcase_21 AC 19 ms
6,944 KB
testcase_22 AC 12 ms
6,940 KB
testcase_23 AC 14 ms
6,940 KB
testcase_24 AC 75 ms
19,216 KB
testcase_25 AC 77 ms
18,404 KB
testcase_26 AC 77 ms
17,796 KB
testcase_27 AC 77 ms
17,816 KB
testcase_28 AC 75 ms
18,812 KB
testcase_29 AC 76 ms
18,568 KB
testcase_30 AC 76 ms
19,188 KB
testcase_31 AC 76 ms
18,564 KB
testcase_32 AC 75 ms
18,404 KB
testcase_33 AC 75 ms
18,764 KB
testcase_34 AC 1 ms
6,940 KB
testcase_35 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unnecessary parentheses around type
  --> src/main.rs:33:15
   |
33 | fn readi() -> (i64) {
   |               ^   ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
33 - fn readi() -> (i64) {
33 + fn readi() -> i64 {
   |

warning: unused variable: `p`
   --> src/main.rs:134:13
    |
134 |     let mut p = (0 as f64, 0 as f64);
    |             ^ help: if this is intentional, prefix it with an underscore: `_p`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: variable does not need to be mutable
   --> src/main.rs:134:9
    |
134 |     let mut p = (0 as f64, 0 as f64);
    |         ----^
    |         |
    |         help: remove this `mut`
    |
    = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
   --> src/main.rs:136:14
    |
136 |         let (mut a, mut b) = readff();
    |              ----^
    |              |
    |              help: remove this `mut`

warning: variable does not need to be mutable
   --> src/main.rs:136:21
    |
136 |         let (mut a, mut b) = readff();
    |                     ----^
    |                     |
    |                     help: remove this `mut`

ソースコード

diff #

// -*- coding:utf-8-unix -*-

#![allow(dead_code)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::mem;
use std::str;
use std::vec;

const INF: i64 = 1223372036854775807;
const MEM_SIZE: usize = 202020;
const MOD: i64 = 1000000007;
// const MOD: i64 = 998244353;

use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn readi() -> (i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    iter.next().unwrap().parse::<i64>().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}

fn readff() -> (f64, f64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<f64>().unwrap(),
        iter.next().unwrap().parse::<f64>().unwrap(),
    )
}

#[allow(dead_code)]
fn readiii() -> (i64, i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

fn readcc() -> (char, char) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<char>().unwrap(),
        iter.next().unwrap().parse::<char>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuu() -> (usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuuu() -> (usize, usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

fn solve() {
    let n: usize = read();
    let mut v = vec![(0 as f64, 0 as usize, 0 as usize); 0];
    let mut vec = vec![(0 as f64, 0 as f64, 0 as f64); n];
    let mut p = (0 as f64, 0 as f64);
    for i in 0..n {
        let (mut a, mut b) = readff();
        // let a = a as i32;
        vec[i].1 = a;
        vec[i].2 = b;
    }
    for i in 0..n {
        for j in i + 1..n {
            if i == j {
                continue;
            }
            let mut d = (vec[i].2 - vec[j].2) * (vec[i].2 - vec[j].2)
                + (vec[i].1 - vec[j].1) * (vec[i].1 - vec[j].1);
            d = d.sqrt();
            // vec[i].0 = d;
            v.push((d, i, j));
        }
    }
    v.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());
    // println!("{:?}", v);
    let mut res = 0 as usize;
    let mut used = vec![0; n];
    for i in 0..v.len() {
        let p = v[i];
        if used[p.1] == 1 || used[p.2] == 1 {
            continue;
        }
        if p.1 == 0 {
            res += 1;
            used[p.2] = 1;
        } else {
            used[p.1] = 1;
            used[p.2] = 1;
        }
        // println!("{:?}", used);
    }
    println!("{:?}", res);

    return;
}

fn main() {
    solve()
}
0