結果

問題 No.1703 Much Matching
ユーザー phsplsphspls
提出日時 2022-10-29 18:43:44
言語 Rust
(1.77.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 1,062 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 135,208 KB
実行使用メモリ 10,648 KB
最終ジャッジ日時 2023-09-20 21:13:34
合計ジャッジ時間 7,699 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 9 ms
6,676 KB
testcase_06 AC 49 ms
5,360 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 55 ms
8,224 KB
testcase_09 AC 60 ms
6,696 KB
testcase_10 AC 10 ms
4,376 KB
testcase_11 AC 18 ms
5,112 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 25 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 19 ms
7,164 KB
testcase_16 AC 31 ms
4,376 KB
testcase_17 AC 37 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 76 ms
6,164 KB
testcase_20 AC 10 ms
4,376 KB
testcase_21 AC 91 ms
7,220 KB
testcase_22 AC 41 ms
7,380 KB
testcase_23 AC 30 ms
4,840 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 7 ms
4,380 KB
testcase_26 AC 25 ms
7,492 KB
testcase_27 AC 39 ms
4,380 KB
testcase_28 AC 79 ms
9,300 KB
testcase_29 AC 19 ms
5,616 KB
testcase_30 AC 24 ms
5,308 KB
testcase_31 AC 5 ms
4,380 KB
testcase_32 AC 44 ms
6,380 KB
testcase_33 AC 33 ms
7,664 KB
testcase_34 AC 4 ms
4,384 KB
testcase_35 AC 9 ms
4,380 KB
testcase_36 AC 173 ms
10,596 KB
testcase_37 AC 16 ms
10,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut nmq = String::new();
    std::io::stdin().read_line(&mut nmq).ok();
    let nmq: Vec<usize> = nmq.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nmq[0];
    let m = nmq[1];
    let q = nmq[2];
    let mut checked = vec![vec![false; m]; n];
    for _ in 0..q {
        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;
        checked[a][b] = true;
    }

    let mut dp = vec![vec![0usize; m+1]; n+1];
    for i in 0..=n {
        for j in 0..=m {
            if i+1 <= n {
                dp[i+1][j] = dp[i+1][j].max(dp[i][j]);
            }
            if j+1 <= m {
                dp[i][j+1] = dp[i][j+1].max(dp[i][j]);
            }
            if i+1 <= n && j+1 <= m {
                dp[i+1][j+1] = dp[i+1][j+1].max(dp[i][j] + if checked[i][j] { 1 } else { 0 });
            }
        }
    }
    println!("{}", dp[n][m]);
}
0