結果
問題 | No.1703 Much Matching |
ユーザー |
![]() |
提出日時 | 2021-10-08 22:22:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 350 ms / 2,000 ms |
コード長 | 1,689 bytes |
コンパイル時間 | 2,137 ms |
コンパイル使用メモリ | 175,188 KB |
実行使用メモリ | 22,656 KB |
最終ジャッジ日時 | 2024-07-23 04:54:24 |
合計ジャッジ時間 | 5,585 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>//#include <atcoder/all>using namespace std;//using namespace atcoder;//using mint = modint1000000007;//const int mod = 1000000007;//using mint = modint998244353;//const int mod = 998244353;//const int INF = 1e9;//const long long LINF = 1e18;//const bool debug = false;#define rep(i, n) for (int i = 0; i < (n); ++i)#define rep2(i,l,r)for(int i=(l);i<(r);++i)#define rrep(i, n) for (int i = (n-1); i >= 0; --i)#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)#define all(x) (x).begin(),(x).end()#define allR(x) (x).rbegin(),(x).rend()#define endl "\n"#define P pair<int,int>template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }bool comp(const P& lh, const P& rh) {if (lh.first < rh.first)return true;else if (lh.first > rh.first)return false;return lh.second > rh.second;}template<class T> int LIS(vector<T> a, bool is_strong = true) {const T INF = 1 << 30; // to be set appropriatelyint n = (int)a.size();vector<T> dp(n, INF);for (int i = 0; i < n; ++i) {if (is_strong) *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];else *upper_bound(dp.begin(), dp.end(), a[i]) = a[i];}return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();}int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int n, m, q; cin >> n >> m >> q;vector<P>v(q);rep(i, q) {int a, b; cin >> a >> b; a--; b--;v[i] = { a,b };}sort(all(v), comp);vector<int>v2(q);rep(i, q)v2[i] = v[i].second;cout << LIS(v2) << endl;return 0;}