結果
| 問題 |
No.1703 Much Matching
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-08 22:31:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,398 bytes |
| コンパイル時間 | 2,427 ms |
| コンパイル使用メモリ | 199,356 KB |
| 最終ジャッジ日時 | 2025-01-24 22:44:09 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 WA * 11 TLE * 23 |
ソースコード
#include <bits/stdc++.h>
using ll = long long;
using std::cin;
using std::cout;
using std::endl;
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <class T>
inline bool chmax(T &a, T b)
{
if (a < b)
{
a = b;
return 1;
}
return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
if (a > b)
{
a = b;
return 1;
}
return 0;
}
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;
void solve([[maybe_unused]] int CASE)
{
int n, m, q;
cin >> n >> m >> q;
std::vector<std::pair<int, int>> vp(q);
for (int i = 0; i < q; ++i)
{
cin >> vp[i].first >> vp[i].second;
}
std::vector dp(2, std::vector<int>(q + 1, -1));
int cur = 0, nxt = 1;
dp[0][0] = 0;
for (int i = 0; i < q; ++i)
{
std::fill(dp[nxt].begin(), dp[nxt].end(), -1);
for (int j = 0; j <= i; ++j)
{
if (dp[cur][j] == -1)
continue;
if (vp[j].first < vp[i].first and vp[j].second < vp[i].second)
{
chmax(dp[nxt][i], dp[cur][j] + 1);
}
chmax(dp[nxt][j], dp[cur][j]);
}
chmax(dp[nxt][i], 1);
std::swap(cur, nxt);
}
cout << *std::max_element(dp[cur].begin(), dp[cur].end()) << endl;
}
int main()
{
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int kkt = 1;
// cin >> kkt;
for (int jupi = 1; jupi <= kkt; jupi++)
solve(jupi);
return 0;
}