Submission #1127679

#TimeUsernameProblemLanguageResultExecution timeMemory
1127679Chal1shkantrapezoid (balkan11_trapezoid)C++20
55 / 100
144 ms131072 KiB
# include <bits/stdc++.h> using namespace std; # define ll long long # define ld long double # define pii pair <int, int> # define pll pair <ll, ll> # define nl '\n' # define sz(x) (int)(x).size() # define all(x) (x).begin(), (x).end() # define deb(x) cerr << #x << " = " << x << endl; const int maxn = (int)1e5 + 3; const ll inf = (ll)1e18 + 0; const int mod = (int)30013; const bool T = 0; int add (int x, int y) { int res = x + y; if (res >= mod) res -= mod; return res; } int n; vector<array<int, 4> > arr; vector <int> zh; int get (int x) { return lower_bound(all(zh), x) - zh.begin(); } pii combine (pii L, pii R) { if (L.first > R.first) { return L; } if (L.first < R.first) { return R; } return {L.first, add(L.second, R.second)}; } int N; struct segtree { pii t[maxn * 4]; void build (int v = 1, int tl = 0, int tr = N - 1) { t[v].first = 0; t[v].second = 0; if (tl == tr) return; int tm = (tl + tr) >> 1; build(v * 2, tl, tm); build(v * 2 + 1, tm + 1, tr); } void update (int pos, pii x, int v = 1, int tl = 0, int tr = N - 1) { if (tl == tr) { t[v] = combine(t[v], x); return; } int tm = (tl + tr) >> 1; if (pos <= tm) update(pos, x, v * 2, tl, tm); else update(pos, x, v * 2 + 1, tm + 1, tr); t[v] = combine(t[v * 2], t[v * 2 + 1]); } pii get (int l, int r, int v = 1, int tl = 0, int tr = N - 1) { if (tr < l || r < tl) return {0, 0}; if (l <= tl && tr <= r) return t[v]; int tm = (tl + tr) >> 1; return combine(get(l, r, v * 2, tl, tm), get(l, r, v * 2 + 1, tm + 1, tr)); } } st; pii dp[maxn]; void ma1n () { cin >> n; arr.resize(n); for (auto &it : arr) { cin >> it[0] >> it[1] >> it[2] >> it[3]; for (int j = 0; j < 4; ++j) zh.push_back(it[j]); } sort(all(zh)); zh.erase(unique(all(zh)), zh.end()); vector <array<int, 3> > e; for (int i = 0; i < n; ++i) { auto &it = arr[i]; for (int j = 0; j < 4; ++j) { it[j] = get(it[j]); } e.push_back({it[0], 1, i}); e.push_back({it[1], 0, i}); } N = sz(zh); st.build(); sort(all(e)); for (auto it : e) { int i = it[2]; if (it[1] == 0) { st.update(arr[i][3], dp[i]); } else { pii p = st.get(0, arr[i][2] - 1); dp[i] = {p.first + 1, p.second}; if (dp[i].first == 1) dp[i].second = 1; } } int mx = 0, var = 0; for (int i = 1; i <= n; ++i) { if (dp[i].first == mx) { var = add(var, dp[i].second); } else if (dp[i].first > mx) { mx = dp[i].first; var = dp[i].second; } } cout << mx << ' ' << var << nl; } signed main () { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int ttt = 1; if (T) cin >> ttt; while (ttt--) { ma1n(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...