結果
問題 |
No.709 優勝可能性
|
ユーザー |
|
提出日時 | 2023-01-01 16:03:12 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 223 ms / 3,500 ms |
コード長 | 1,386 bytes |
コンパイル時間 | 13,928 ms |
コンパイル使用メモリ | 396,340 KB |
実行使用メモリ | 27,196 KB |
最終ジャッジ日時 | 2024-11-27 00:06:54 |
合計ジャッジ時間 | 17,494 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
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 r = (0..n).map(|_| { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp: Vec<usize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); temp }) .collect::<Vec<_>>(); let mut maxvals = r[0].clone().to_owned(); let mut players = vec![vec![0]; m]; let mut cntmap = HashMap::new(); cntmap.insert(0usize, m); println!("1"); for i in 1..n { for j in 0..m { if maxvals[j] < r[i][j] { for &v in players[j].iter() { *cntmap.entry(v).or_insert(0usize) -= 1; if *cntmap.get(&v).unwrap() == 0 { cntmap.remove(&v); } } players[j] = vec![i]; maxvals[j] = r[i][j]; *cntmap.entry(i).or_insert(0usize) += 1; } else if maxvals[j] == r[i][j] { players[j].push(i); *cntmap.entry(i).or_insert(0usize) += 1; } } println!("{}", cntmap.len()); } }