# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
377670 | 2021-03-14T16:51:36 Z | ntabc05101 | trapezoid (balkan11_trapezoid) | C++14 | 292 ms | 39108 KB |
#ifndef LOCAL #define NDEBUG 1 #endif // LOCAL #include<bits/stdc++.h> #define taskname "" #define f first #define s second const int max_n=500000; const int inf=1e9+9; const int mod=30013; std::vector<int> pList[max_n+1]; std::pair<int, int> bits[max_n+1]; void update(int x, std::pair<int, int> delta) { for (; x<=max_n; x+=x&-x) { if (bits[x].f<delta.f) { bits[x]=delta; } else if (bits[x].f==delta.f) { bits[x].s+=delta.s; if (bits[x].s>=mod) { bits[x].s-=mod; } } } } std::pair<int, int> get(int x) { std::pair<int, int> ret={0, 0}; for (; x>0; x&=x-1) { if (ret.f<bits[x].f) { ret=bits[x]; } else if (ret.f==bits[x].f) { ret.s+=bits[x].s; if (ret.s>=mod) { ret.s-=mod; } } } return ret; } int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } else if (fopen(taskname".in", "r")) { freopen(taskname".in", "r", stdin); freopen(taskname".out", "w", stdout); } std::ios_base::sync_with_stdio(0); std::cin.tie(0); int n; std::cin>>n; int a[n][4]; std::vector<int> points; points.push_back(inf); for (int i=0; i<n; ++i) { for (int j=0; j<4; ++j) { std::cin>>a[i][j]; points.push_back(a[i][j]); } } std::sort(begin(points), end(points)); points.resize(std::distance(begin(points), std::unique(begin(points), end(points)))); std::unordered_map<int, int> compress; #define cpoint(x) (compress.count(x)>0 ? compress[x]: compress[x]=std::lower_bound(begin(points), end(points), x)-begin(points)+1) for (int i=0; i<n; ++i) { for (int j=0; j<4; ++j) { a[i][j]=cpoint(a[i][j]); } pList[a[i][0]].push_back(i); pList[a[i][1]].push_back(i+n); } /*for (int i=0; i<n; ++i) { for (int j=0; j<4; ++j) std::cout<<a[i][j]<<" "; std::cout<<"\n"; }*/ update(1, {0, 1}); std::pair<int, int> result[n]; for (int i=1; i<=4*n; ++i) { for (auto& p: pList[i]) { if (p<n) { result[p]=get(a[p][2]); ++result[p].f; } else { update(a[p-n][3], result[p-n]); } } } auto ret=get(4*n+1); std::cout<<ret.f<<" "<<ret.s<<"\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 12160 KB | Output is correct |
2 | Correct | 9 ms | 12140 KB | Output is correct |
3 | Correct | 9 ms | 12268 KB | Output is correct |
4 | Correct | 10 ms | 12268 KB | Output is correct |
5 | Correct | 15 ms | 12652 KB | Output is correct |
6 | Correct | 15 ms | 13036 KB | Output is correct |
7 | Correct | 15 ms | 13128 KB | Output is correct |
8 | Correct | 18 ms | 13292 KB | Output is correct |
9 | Correct | 29 ms | 14972 KB | Output is correct |
10 | Correct | 43 ms | 16236 KB | Output is correct |
11 | Correct | 71 ms | 19204 KB | Output is correct |
12 | Correct | 166 ms | 26404 KB | Output is correct |
13 | Correct | 173 ms | 28684 KB | Output is correct |
14 | Correct | 238 ms | 33680 KB | Output is correct |
15 | Correct | 217 ms | 30584 KB | Output is correct |
16 | Correct | 232 ms | 31972 KB | Output is correct |
17 | Correct | 289 ms | 36752 KB | Output is correct |
18 | Correct | 186 ms | 30336 KB | Output is correct |
19 | Correct | 275 ms | 38160 KB | Output is correct |
20 | Correct | 292 ms | 39108 KB | Output is correct |