Submission #1129481

#TimeUsernameProblemLanguageResultExecution timeMemory
1129481steveonalextrapezoid (balkan11_trapezoid)C++20
100 / 100
145 ms23736 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define MASK(i) (1ULL << (i)) #define GETBIT(mask, i) (((mask) >> (i)) & 1) #define ALL(v) (v).begin(), (v).end() #define block_of_code if(true) ll max(ll a, ll b){return (a > b) ? a : b;} ll min(ll a, ll b){return (a < b) ? a : b;} ll gcd(ll a, ll b){return __gcd(a, b);} ll lcm(ll a, ll b){return a / gcd(a, b) * b;} ll LASTBIT(ll mask){return (mask) & (-mask);} int pop_cnt(ull mask){return __builtin_popcountll(mask);} int ctz(ull mask){return __builtin_ctzll(mask);} int logOf(ull mask){return 63 - __builtin_clzll(mask);} mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);} double rngesus_d(double l, double r){ double cur = rngesus(0, MASK(60) - 1); cur /= MASK(60) - 1; return l + cur * (r - l); } template <class T1, class T2> bool maximize(T1 &a, T2 b){ if (a < b) {a = b; return true;} return false; } template <class T1, class T2> bool minimize(T1 &a, T2 b){ if (a > b) {a = b; return true;} return false; } template <class T> void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){ for(auto item: container) out << item << separator; out << finish; } template <class T> void remove_dup(vector<T> &a){ sort(ALL(a)); a.resize(unique(ALL(a)) - a.begin()); } const int MOD = 30013; struct Modular{ ll x; Modular(ll _x = 0){ x = _x % MOD; if (x < 0) x += MOD; } Modular& operator += (Modular y){ x += y.x; if (x >= MOD) x -= MOD; return *this; } Modular operator + (Modular y) { Modular tmp = *this; return tmp += y; } Modular& operator -= (Modular y){ x -= y.x; if (x < 0) x += MOD; return *this; } Modular operator - (Modular y) { Modular tmp = *this; return tmp -= y; } Modular& operator *= (Modular y){ x *= y.x; if (x >= MOD) x %= MOD; return *this; } Modular operator * (Modular y) { Modular tmp = *this; return tmp *= y; } // use at your own risk bool operator == (Modular y){ return x == y.x; } bool operator != (Modular y){ return x != y.x; } }; ostream& operator << (ostream& out, Modular x){ out << x.x; return out; } Modular fast_pow(Modular a, int n){ Modular ans = 1; while(n > 0){ if (n & 1) ans *= a; a *= a; n >>= 1; } return ans; } Modular inverse(Modular a){return fast_pow(a, MOD - 2);} struct Node{ int val; Modular cnt; Node(int val, Modular cnt): val(val), cnt(cnt){} }; Node combine(Node a, Node b){ Node c(max(a.val, b.val), 0); if (a.val == c.val) c.cnt += a.cnt; if (b.val == c.val) c.cnt += b.cnt; return c; } struct FenwickTree{ int n; vector<Node> a; FenwickTree(int _n){ n = _n; for(int i = 0; i <= n; ++i) a.push_back(Node(0, 0)); } void update(int i, Node v){ while(i <= n){ a[i] = combine(a[i], v); i += LASTBIT(i); } } Node get(int i){ Node ans(0, 0); while(i > 0){ ans = combine(ans, a[i]); i -= LASTBIT(i); } return ans; } }; void solve(){ int n; cin >> n; vector<array<int, 4>> rape_zoid(n); for(int i =0; i<n; ++i) for(int j = 0; j< 4; ++j) cin >> rape_zoid[i][j]; vector<int> X = {0}, Y = {0}; for(auto i: rape_zoid){ X.push_back(i[0]); X.push_back(i[1]); Y.push_back(i[2]); Y.push_back(i[3]); } remove_dup(X); remove_dup(Y); for(auto &i: rape_zoid){ i[0] = lower_bound(ALL(X), i[0]) - X.begin(); i[1] = lower_bound(ALL(X), i[1]) - X.begin(); i[2] = lower_bound(ALL(Y), i[2]) - Y.begin(); i[3] = lower_bound(ALL(Y), i[3]) - Y.begin(); } int x = X.size() - 1, y = Y.size() - 1; FenwickTree bit(y); vector<vector<int>> enter_query(x + 1), exit_query(x + 1); vector<Node> lmao(n, Node(0, 0)); for(int i = 0; i< n; ++i){ enter_query[rape_zoid[i][0]].push_back(i); exit_query[rape_zoid[i][1]].push_back(i); } for(int i = 1; i <= x; ++i){ for(int j: exit_query[i]){ bit.update(rape_zoid[j][3], lmao[j]); } for(int j: enter_query[i]){ Node cur = bit.get(rape_zoid[j][2]); cur.val++; if (cur.val == 1) cur.cnt = 1; lmao[j] = cur; } } Node ans(0, 0); for(int i = 0; i < n; ++i) ans = combine(ans, lmao[i]); cout << ans.val << " " << ans.cnt << "\n"; } int main(void){ ios::sync_with_stdio(0);cin.tie(0); cout.tie(0); clock_t start = clock(); solve(); cerr << "Time elapsed: " << clock() - start << " ms\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...