結果

問題 No.1703 Much Matching
ユーザー harurunharurun
提出日時 2021-09-03 14:30:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 446 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 81,416 KB
実行使用メモリ 11,104 KB
最終ジャッジ日時 2023-09-30 09:24:36
合計ジャッジ時間 5,118 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 4 ms
5,216 KB
testcase_04 AC 4 ms
4,384 KB
testcase_05 AC 8 ms
7,412 KB
testcase_06 AC 117 ms
6,356 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 135 ms
8,872 KB
testcase_09 AC 148 ms
7,420 KB
testcase_10 AC 20 ms
4,376 KB
testcase_11 AC 35 ms
6,028 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 55 ms
5,140 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 32 ms
7,940 KB
testcase_16 AC 71 ms
4,572 KB
testcase_17 AC 84 ms
5,240 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 189 ms
6,884 KB
testcase_20 AC 21 ms
4,376 KB
testcase_21 AC 228 ms
7,480 KB
testcase_22 AC 93 ms
8,060 KB
testcase_23 AC 65 ms
5,980 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 11 ms
4,384 KB
testcase_26 AC 50 ms
8,204 KB
testcase_27 AC 92 ms
5,220 KB
testcase_28 AC 195 ms
9,664 KB
testcase_29 AC 37 ms
6,556 KB
testcase_30 AC 53 ms
6,196 KB
testcase_31 AC 7 ms
4,448 KB
testcase_32 AC 101 ms
7,240 KB
testcase_33 AC 72 ms
8,408 KB
testcase_34 AC 7 ms
4,380 KB
testcase_35 AC 19 ms
4,380 KB
testcase_36 AC 446 ms
11,104 KB
testcase_37 AC 14 ms
10,948 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