結果

問題 No.408 五輪ピック
ユーザー phsplsphspls
提出日時 2023-01-14 03:33:48
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,392 bytes
コンパイル時間 687 ms
コンパイル使用メモリ 144,092 KB
実行使用メモリ 5,312 KB
最終ジャッジ日時 2023-08-26 07:49:37
合計ジャッジ時間 2,895 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 10 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 11 ms
4,380 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 9 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 12 ms
4,380 KB
testcase_13 AC 10 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 10 ms
4,380 KB
testcase_16 AC 11 ms
4,380 KB
testcase_17 AC 12 ms
4,376 KB
testcase_18 AC 13 ms
4,376 KB
testcase_19 AC 13 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 17 ms
5,312 KB
testcase_24 WA -
testcase_25 AC 11 ms
4,376 KB
testcase_26 AC 15 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 8 ms
4,376 KB
testcase_29 AC 8 ms
4,376 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::collections::HashMap`
 --> Main.rs:1:5
  |
1 | use std::collections::HashMap;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: 1 warning emitted

ソースコード

diff #

use std::collections::HashMap;


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 paths = vec![vec![]; n];
    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;
        paths[a].push(b);
        paths[b].push(a);
    }

    let mut mapping = vec![vec![]; n];
    for &u in paths[0].iter() {
        for &v in paths[u].iter() {
            mapping[v].push(u);
        }
    }
    for i in 0..n {
        if mapping[i].is_empty() { continue; }
        for j in i+1..n {
            if mapping[j].is_empty() { continue; }
            if mapping[i].len() > 2 && mapping[j].len() > 2 {
                println!("YES");
                return;
            } else {
                for &k in mapping[i].iter() {
                    for &l in mapping[j].iter() {
                        if k != j && k != l && l != i {
                            println!("YES");
                            return;
                        }
                    }
                }
            }
        }
    }
    println!("NO");
}
0