結果

問題 No.1703 Much Matching
ユーザー tabae326tabae326
提出日時 2021-10-08 22:33:41
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 465 ms / 2,000 ms
コード長 1,431 bytes
コンパイル時間 2,784 ms
コンパイル使用メモリ 212,572 KB
実行使用メモリ 12,228 KB
最終ジャッジ日時 2023-09-30 11:28:24
合計ジャッジ時間 6,440 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 124 ms
6,868 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 125 ms
6,500 KB
testcase_09 AC 144 ms
6,820 KB
testcase_10 AC 20 ms
4,380 KB
testcase_11 AC 29 ms
4,380 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 53 ms
4,744 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 24 ms
4,380 KB
testcase_16 AC 79 ms
6,036 KB
testcase_17 AC 87 ms
5,472 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 198 ms
9,672 KB
testcase_20 AC 25 ms
4,376 KB
testcase_21 AC 232 ms
11,636 KB
testcase_22 AC 87 ms
6,376 KB
testcase_23 AC 63 ms
5,268 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 9 ms
4,380 KB
testcase_26 AC 41 ms
4,628 KB
testcase_27 AC 93 ms
5,208 KB
testcase_28 AC 185 ms
7,552 KB
testcase_29 AC 33 ms
4,376 KB
testcase_30 AC 49 ms
4,752 KB
testcase_31 AC 5 ms
4,380 KB
testcase_32 AC 99 ms
5,348 KB
testcase_33 AC 63 ms
4,876 KB
testcase_34 AC 6 ms
4,380 KB
testcase_35 AC 16 ms
4,380 KB
testcase_36 AC 465 ms
12,228 KB
testcase_37 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
// Ref: https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define dump(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << "\n";}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << "\n";}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ std::cerr << "\n"; for(const auto& v : vv){ view(v); } }
template<typename T> void dump_cout(const T& v) { for(long long i = 0; i < v.size(); i++) std::cout << v[i] << (i == v.size()-1 ? "\n" : " "); }

#include <atcoder/segtree>
using namespace atcoder;
using S = ll;
S op(S a, S b) { return max(a, b); }
S e() { return 0; }

void solve() {
    ll n, m, q;
    cin >> n >> m >> q;
    vector<vector<ll>> G(n);
    rep(i, 0, q) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
    }
    segtree<S, op, e> seg(m+10);
    rep(i, 0, n) {
        map<ll,ll> tmp;
        for(auto j : G[i]) {
            tmp[j] = max(tmp[j], seg.prod(0, j) + 1);
        }
        for(auto [f, s] : tmp) seg.set(f, max(s, seg.get(f)));
    }
    cout << seg.all_prod() << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
0