# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
623010 | zhangjishen | trapezoid (balkan11_trapezoid) | C++98 | 94 ms | 9632 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool chkmax(T &a, T b){return b > a ? a = b, 1 : 0;}
const int MAXN = 1e5 + 10;
// BIT
int bit[MAXN * 2], siz;
int lsb(int i){
return i & -i;
}
void upd(int i, int k){
for(; i <= siz; i += lsb(i))
chkmax(bit[i], k);
}
int ask(int i){
int ans = 0;
for(; i; i -= lsb(i))
chkmax(ans, bit[i]);
return ans;
}
struct Op{
int x, y, tp, i;
friend bool operator<(const Op& a, const Op& b){
return a.x < b.x;
}
}op[MAXN * 2];
int n, a[MAXN], b[MAXN], c[MAXN], d[MAXN], f[MAXN];
int q, disc[MAXN * 2], tot;
int main(){
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
// disc
for(int i = 1; i <= n; i++)
disc[++tot] = c[i], disc[++tot] = d[i];
sort(disc + 1, disc + tot + 1);
tot = unique(disc + 1, disc + tot + 1) - disc - 1;
for(int i = 1; i <= n; i++){
c[i] = lower_bound(disc + 1, disc + tot + 1, c[i]) - disc;
d[i] = lower_bound(disc + 1, disc + tot + 1, d[i]) - disc;
}
// sort op
for(int i = 1; i <= n; i++){
op[++q] = (Op){a[i], c[i], 2, i};
op[++q] = (Op){b[i], d[i], 1, i};
}
sort(op + 1, op + q + 1);
// dp
siz = tot;
for(int i = 1; i <= q; i++){
if(op[i].tp == 1)
upd(op[i].y, f[op[i].i]);
else f[op[i].i] = ask(op[i].y) + 1;
}
// output
int ans = 0;
for(int i = 1; i <= n; i++)
chkmax(ans, f[i]);
printf("%d 0\n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |