結果

問題 No.1703 Much Matching
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-10-08 22:37:41
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 828 bytes
コンパイル時間 1,414 ms
コンパイル使用メモリ 70,432 KB
最終ジャッジ日時 2023-09-30 11:34:59
合計ジャッジ時間 2,614 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:33:15: エラー: ‘tie’ was not declared in this scope
   33 |     int a, b; tie(a, b) = p;
      |               ^~~
main.cpp:3:1: 備考: ‘std::tie’ is defined in header ‘<tuple>’; did you forget to ‘#include <tuple>’?
    2 | #include<atcoder/segtree>
  +++ |+#include <tuple>
    3 | 

ソースコード

diff #

#include<iostream>
#include<atcoder/segtree>

#define fi first
#define se second

using namespace std;
using namespace atcoder;
using P = pair<int, int>;

int op(int x, int y) { return max(x, y);}
int e() { return -1;}

int main(){
  int N, M, Q; cin >> N >> M >> Q;
  vector<P> AB;
  for(int i=0; i<Q; ++i){
    int a, b; cin >> a >> b;
    AB.emplace_back(make_pair(a, b));
  }
  sort(AB.begin(), AB.end(), [](auto x, auto y){
    if(x.fi < y.fi) return true;
    if(x.fi > y.fi) return false;
    return x.se > y.se;
  });
  
  segtree<int, op, e> seg(max(N, M) + 1);
  vector<int> dp(max(N, M) + 1, -1);
  dp[0] = 0;
  seg.set(0, 0);
  
  for(auto& p: AB){
    int a, b; tie(a, b) = p;
    int x = seg.prod(0, b) + 1;
    dp[b] = x;
    seg.set(b, x);
  }
  
  int ANS = seg.all_prod();
  cout << ANS << endl;
  return 0;
}
0