結果
問題 | No.1703 Much Matching |
ユーザー |
|
提出日時 | 2021-10-09 16:28:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 419 ms / 2,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 1,904 ms |
コンパイル使用メモリ | 177,188 KB |
実行使用メモリ | 7,552 KB |
最終ジャッジ日時 | 2024-09-13 02:20:16 |
合計ジャッジ時間 | 7,292 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i,n) for(int i=0; i<(n); i++)#define INF ((1LL<<62)-(1LL<<31))#define all(a) (a).begin(),(a).end()#define rall(a) (a).rbegin(),(a).rend()typedef long long ll;typedef pair<ll,ll> pl;int main() {int n,m,q;cin >> n >> m >> q;vector<vector<bool>> flag(n,vector<bool> (m,false));rep(i,q) {int a,b;cin >> a >> b;a--; b--;flag[a][b]=true;}vector<vector<int>> dp(n+1,vector<int> (m+1,0));rep(i,n) rep(j,m) {if(flag[i][j]) dp[i+1][j+1]=dp[i][j]+1;else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);}cout << dp[n][m] << endl;return 0;}