結果
問題 | No.1265 Balloon Survival |
ユーザー | Moss_Local |
提出日時 | 2020-10-24 06:24:01 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 65 ms / 2,000 ms |
コード長 | 4,691 bytes |
コンパイル時間 | 13,066 ms |
コンパイル使用メモリ | 392,052 KB |
実行使用メモリ | 19,096 KB |
最終ジャッジ日時 | 2024-07-21 14:55:29 |
合計ジャッジ時間 | 13,988 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,812 KB |
testcase_02 | AC | 1 ms
6,812 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,944 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 | 0 ms
6,944 KB |
testcase_14 | AC | 8 ms
6,940 KB |
testcase_15 | AC | 6 ms
6,940 KB |
testcase_16 | AC | 3 ms
6,940 KB |
testcase_17 | AC | 34 ms
10,348 KB |
testcase_18 | AC | 4 ms
6,940 KB |
testcase_19 | AC | 3 ms
6,944 KB |
testcase_20 | AC | 7 ms
6,944 KB |
testcase_21 | AC | 17 ms
6,944 KB |
testcase_22 | AC | 10 ms
6,944 KB |
testcase_23 | AC | 11 ms
6,940 KB |
testcase_24 | AC | 65 ms
18,216 KB |
testcase_25 | AC | 65 ms
18,680 KB |
testcase_26 | AC | 65 ms
18,380 KB |
testcase_27 | AC | 64 ms
17,820 KB |
testcase_28 | AC | 65 ms
18,468 KB |
testcase_29 | AC | 64 ms
18,224 KB |
testcase_30 | AC | 64 ms
19,096 KB |
testcase_31 | AC | 64 ms
18,256 KB |
testcase_32 | AC | 63 ms
18,348 KB |
testcase_33 | AC | 64 ms
17,800 KB |
testcase_34 | AC | 1 ms
6,940 KB |
testcase_35 | AC | 1 ms
6,940 KB |
コンパイルメッセージ
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) = readii(); | ----^ | | | help: remove this `mut` warning: variable does not need to be mutable --> src/main.rs:136:21 | 136 | let (mut a, mut b) = readii(); | ----^ | | | help: remove this `mut` warning: variable does not need to be mutable --> src/main.rs:146:17 | 146 | let mut d = (vec[i].2 - vec[j].2) * (vec[i].2 - vec[j].2) | ----^ | | | help: remove this `mut`
ソースコード
// -*- 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 i64, 0 as usize, 0 as usize); 0]; let mut vec = vec![(0 as i64, 0 as i64, 0 as i64); n]; let mut p = (0 as f64, 0 as f64); for i in 0..n { let (mut a, mut b) = readii(); // 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() }