結果

問題 No.1703 Much Matching
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-03 16:08:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,628 ms / 2,000 ms
コード長 743 bytes
コンパイル時間 1,050 ms
コンパイル使用メモリ 116,656 KB
実行使用メモリ 54,188 KB
最終ジャッジ日時 2023-08-28 07:58:58
合計ジャッジ時間 10,002 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 5 ms
4,476 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 9 ms
5,660 KB
testcase_06 AC 336 ms
17,644 KB
testcase_07 AC 13 ms
4,380 KB
testcase_08 AC 374 ms
19,716 KB
testcase_09 AC 426 ms
20,828 KB
testcase_10 AC 41 ms
6,000 KB
testcase_11 AC 73 ms
8,156 KB
testcase_12 AC 12 ms
4,380 KB
testcase_13 AC 131 ms
10,396 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 66 ms
8,384 KB
testcase_16 AC 194 ms
12,644 KB
testcase_17 AC 229 ms
14,024 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 606 ms
25,896 KB
testcase_20 AC 44 ms
6,032 KB
testcase_21 AC 738 ms
30,092 KB
testcase_22 AC 250 ms
15,044 KB
testcase_23 AC 164 ms
11,684 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 20 ms
4,828 KB
testcase_26 AC 110 ms
10,308 KB
testcase_27 AC 267 ms
14,888 KB
testcase_28 AC 604 ms
26,428 KB
testcase_29 AC 82 ms
8,556 KB
testcase_30 AC 121 ms
10,224 KB
testcase_31 AC 13 ms
4,496 KB
testcase_32 AC 272 ms
16,072 KB
testcase_33 AC 170 ms
12,856 KB
testcase_34 AC 12 ms
4,376 KB
testcase_35 AC 37 ms
5,796 KB
testcase_36 AC 1,628 ms
54,188 KB
testcase_37 AC 19 ms
7,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    int N, M, Q, a, b;
    cin >> N >> M >> Q;
    set<pair<int, int>> st;
    for (int i=0; i<Q; i++){
        cin >> a >> b;
        st.insert({a, b});
    }

    vector<vector<int>> dp(N+1, vector<int>(M+1));

    for (int i=1; i<=N; i++){
        for (int j=1; j<=M; j++){
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (st.count({i, j})) dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
        }
    }

    cout << dp[N][M] << endl;

    return 0;
}
0