結果

問題 No.1703 Much Matching
ユーザー harurunharurun
提出日時 2021-09-03 14:39:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 421 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 80,184 KB
実行使用メモリ 10,936 KB
最終ジャッジ日時 2023-09-30 09:26:06
合計ジャッジ時間 5,082 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 5 ms
5,188 KB
testcase_04 AC 3 ms
4,684 KB
testcase_05 AC 7 ms
7,240 KB
testcase_06 AC 106 ms
6,272 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 120 ms
9,048 KB
testcase_09 AC 129 ms
7,232 KB
testcase_10 AC 19 ms
4,380 KB
testcase_11 AC 34 ms
6,024 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 52 ms
5,648 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 30 ms
7,832 KB
testcase_16 AC 67 ms
4,600 KB
testcase_17 AC 78 ms
5,280 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 169 ms
6,780 KB
testcase_20 AC 21 ms
4,376 KB
testcase_21 AC 217 ms
7,476 KB
testcase_22 AC 87 ms
8,136 KB
testcase_23 AC 61 ms
5,572 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 10 ms
4,380 KB
testcase_26 AC 48 ms
8,028 KB
testcase_27 AC 88 ms
5,044 KB
testcase_28 AC 193 ms
9,580 KB
testcase_29 AC 36 ms
6,596 KB
testcase_30 AC 51 ms
6,324 KB
testcase_31 AC 7 ms
4,376 KB
testcase_32 AC 95 ms
7,328 KB
testcase_33 AC 66 ms
8,304 KB
testcase_34 AC 6 ms
4,376 KB
testcase_35 AC 17 ms
4,456 KB
testcase_36 AC 421 ms
10,936 KB
testcase_37 AC 13 ms
10,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int lcs(int N,int M,vector<vector<int>>& check){
  vector<vector<int>> dp(N+1,vector<int>(M+1,0));
  for(int i=1;i<N+1;i++){
    for(int j=1;j<M+1;j++){
      if(check.at(i-1).at(j-1)==1){
        dp.at(i).at(j)=dp.at(i-1).at(j-1)+1;
      }else{
        dp.at(i).at(j)=max(dp.at(i-1).at(j),dp.at(i).at(j-1));
      }
    }
  }
  return dp.at(N).at(M);
}

int main(){
  int N,M,Q,a,b;
  cin>>N>>M>>Q;
  vector<vector<int>>check(N,vector<int>(M,0));
  for(int i=0;i<Q;i++){
    cin>>a>>b;
    check.at(a-1).at(b-1)=1;
  }
  printf("%d\n",lcs(N,M,check));
  return 0;
}
0