結果
問題 |
No.2563 色ごとのグループ
|
ユーザー |
|
提出日時 | 2024-07-23 18:22:34 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 583 bytes |
コンパイル時間 | 27,175 ms |
コンパイル使用メモリ | 383,512 KB |
実行使用メモリ | 32,724 KB |
最終ジャッジ日時 | 2024-07-23 18:23:06 |
合計ジャッジ時間 | 28,463 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 WA * 5 |
ソースコード
use std::collections::{HashMap, HashSet}; fn g() -> Vec<usize> { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.split_whitespace().flat_map(str::parse).collect() } fn main() { let n = g(); let mut c = g(); let mut h = HashMap::<_, HashSet<_>>::new(); let mut a = 0; for _ in 0..n[1] { let v = g(); if c[v[0] - 1] != c[v[1] - 1] { continue; } let s = h.entry(v[0]).or_insert(HashSet::new()); a += (s.insert(v[0]) || s.insert(v[1])) as i32; } c.sort(); println!( "{}", c.windows(2).fold(0, |t, x| t + (x[0] == x[1]) as i32) - a ) }