結果
| 問題 |
No.1147 土偶Ⅱ
|
| ユーザー |
|
| 提出日時 | 2020-08-05 23:14:14 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 500 ms |
| コード長 | 1,439 bytes |
| コンパイル時間 | 15,504 ms |
| コンパイル使用メモリ | 403,772 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-11 10:13:07 |
| 合計ジャッジ時間 | 16,564 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
コンパイルメッセージ
warning: unused borrow that must be used
--> src/main.rs:24:9
|
24 | / &relations[i].iter().for_each(|&f| {
25 | | if f == i { return; }
26 | | (&relations[f]).iter().for_each(|&k| {
27 | | if !(&relations[k]).contains(&i) {
... |
30 | | });
31 | | });
| |__________^ the borrow produces a value
|
= note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
|
24 | let _ = &relations[i].iter().for_each(|&f| {
| +++++++
ソースコード
use std::collections::HashSet;
fn main() {
let mut nm = String::new();
std::io::stdin().read_line(&mut nm).ok();
let nm: Vec<usize> = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
let n = nm[0];
let m = nm[1];
let mut relations: Vec<HashSet<usize>> = vec![HashSet::new(); n];
for i in 0..n {
relations[i].insert(i);
}
for _ in 0..m {
let mut ab = String::new();
std::io::stdin().read_line(&mut ab).ok();
let ab: Vec<usize> = ab.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
let a = ab[0] - 1;
let b = ab[1] - 1;
relations[a].insert(b);
relations[b].insert(a);
}
let mut ffriends: Vec<HashSet<usize>> = vec![HashSet::new(); n];
for i in 0..n {
&relations[i].iter().for_each(|&f| {
if f == i { return; }
(&relations[f]).iter().for_each(|&k| {
if !(&relations[k]).contains(&i) {
ffriends[i].insert(k);
}
});
});
}
let mut result: usize = 0;
for i in 0..n {
for j in i+1..n {
if ffriends[i].contains(&j) { continue; }
for k in j+1..n {
if ffriends[i].contains(&k) { continue; }
if ffriends[j].contains(&k) { continue; }
result += 1;
}
}
}
println!("{}", result);
}