結果

問題 No.1703 Much Matching
ユーザー harurunharurun
提出日時 2021-09-03 14:29:05
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 500 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 95,996 KB
実行使用メモリ 11,076 KB
最終ジャッジ日時 2023-09-30 09:24:31
合計ジャッジ時間 5,563 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 4 ms
5,272 KB
testcase_04 AC 3 ms
4,644 KB
testcase_05 AC 6 ms
7,364 KB
testcase_06 AC 129 ms
6,280 KB
testcase_07 AC 8 ms
4,380 KB
testcase_08 AC 146 ms
8,968 KB
testcase_09 AC 161 ms
7,344 KB
testcase_10 AC 21 ms
4,376 KB
testcase_11 AC 36 ms
6,068 KB
testcase_12 AC 8 ms
4,380 KB
testcase_13 AC 60 ms
5,540 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 33 ms
7,868 KB
testcase_16 AC 77 ms
4,644 KB
testcase_17 AC 92 ms
5,256 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 207 ms
6,848 KB
testcase_20 AC 23 ms
4,380 KB
testcase_21 AC 251 ms
7,984 KB
testcase_22 AC 103 ms
8,132 KB
testcase_23 AC 71 ms
5,700 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 11 ms
4,388 KB
testcase_26 AC 53 ms
8,152 KB
testcase_27 AC 102 ms
5,224 KB
testcase_28 AC 216 ms
9,720 KB
testcase_29 AC 40 ms
6,588 KB
testcase_30 AC 58 ms
6,280 KB
testcase_31 AC 8 ms
4,500 KB
testcase_32 AC 112 ms
7,292 KB
testcase_33 AC 78 ms
8,396 KB
testcase_34 AC 7 ms
4,376 KB
testcase_35 AC 19 ms
4,460 KB
testcase_36 AC 500 ms
11,040 KB
testcase_37 AC 10 ms
11,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/dsu>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
using namespace atcoder;

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;
  dsu uf(N+M);
  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