답안 #305066

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305066 2020-09-22T13:57:22 Z HynDuf 사다리꼴 (balkan11_trapezoid) C++11
100 / 100
104 ms 6628 KB
#include <bits/stdc++.h>

#define task "T"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int N = 1e5 + 2, mod = 30013;
struct Trape
{
    int x1, x2, y1, y2;
} tra[N];
int n;
vi comy;
vii event;
ii bit[N << 1], dp[N];
void upd(int p, int len, int num)
{
    for (; p <= 2 * n; p += p & -p) if (bit[p].F == len) (bit[p].S += num) %= mod;
    else if (bit[p].F < len) bit[p] = {len, num};
}
ii query(int p)
{
    ii res;
    for (; p; p -= p & -p) if (bit[p].F > res.F) res = bit[p];
    else if (bit[p].F == res.F) (res.S += bit[p].S) %= mod;
    return res;
}
int main()
{
#ifdef HynDuf
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif
    cin >> n;
    rep(i, 1, n)
    {
        int x1, x2, y1, y2;
        cin >> x1 >> x2 >> y1 >> y2;
        tra[i] = {x1, x2, y1, y2};
        comy.eb(y1);
        comy.eb(y2);
    }
    sort(all(comy));
    rep(i, 1, n)
    {
        tra[i].y1 = lower_bound(all(comy), tra[i].y1) - comy.begin() + 1;
        tra[i].y2 = lower_bound(all(comy), tra[i].y2) - comy.begin() + 1;
        event.eb(tra[i].x1, i);
        event.eb(tra[i].x2, -i);
    }
    ii ans = {0, 0};
    sort(all(event));
    for (ii E : event)
    {
        if (E.S > 0)
        {
            ii mx = query(tra[E.S].y1);
            if (!mx.F) mx.S = 1;
            dp[E.S] = {mx.F + 1, mx.S};
            if (ans.F < dp[E.S].F) ans = dp[E.S];
            else if (ans.F == dp[E.S].F) (ans.S += dp[E.S].S) %= mod;
        } else upd(tra[-E.S].y2, dp[-E.S].F, dp[-E.S].S);
    }
    cout << ans.F << ' ' << ans.S;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 4 ms 640 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 10 ms 1148 KB Output is correct
10 Correct 19 ms 1784 KB Output is correct
11 Correct 24 ms 2032 KB Output is correct
12 Correct 52 ms 3568 KB Output is correct
13 Correct 61 ms 4260 KB Output is correct
14 Correct 75 ms 4972 KB Output is correct
15 Correct 84 ms 5356 KB Output is correct
16 Correct 88 ms 5472 KB Output is correct
17 Correct 93 ms 5740 KB Output is correct
18 Correct 90 ms 6124 KB Output is correct
19 Correct 102 ms 6252 KB Output is correct
20 Correct 104 ms 6628 KB Output is correct