結果

問題 No.709 優勝可能性
ユーザー phsplsphspls
提出日時 2023-01-01 16:03:12
言語 Rust
(1.77.0)
結果
AC  
実行時間 236 ms / 3,500 ms
コード長 1,386 bytes
コンパイル時間 1,258 ms
コンパイル使用メモリ 159,404 KB
実行使用メモリ 27,776 KB
最終ジャッジ日時 2023-08-17 23:04:37
合計ジャッジ時間 6,464 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 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 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 157 ms
9,176 KB
testcase_11 AC 147 ms
9,124 KB
testcase_12 AC 183 ms
12,304 KB
testcase_13 AC 205 ms
18,252 KB
testcase_14 AC 186 ms
18,296 KB
testcase_15 AC 188 ms
18,612 KB
testcase_16 AC 208 ms
19,840 KB
testcase_17 AC 236 ms
27,776 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 212 ms
18,236 KB
testcase_21 AC 211 ms
18,252 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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 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());
    }
}
0