結果

問題 No.1703 Much Matching
ユーザー 👑 jupirojupiro
提出日時 2021-10-08 22:31:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,398 bytes
コンパイル時間 2,311 ms
コンパイル使用メモリ 206,388 KB
実行使用メモリ 12,712 KB
最終ジャッジ日時 2023-09-30 11:23:42
合計ジャッジ時間 6,160 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,760 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0