Submission #305066

#TimeUsernameProblemLanguageResultExecution timeMemory
305066HynDuftrapezoid (balkan11_trapezoid)C++11
100 / 100
104 ms6628 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...