Submission #567312

# Submission time Handle Problem Language Result Execution time Memory
567312 2022-05-23T10:25:41 Z hgmhc trapezoid (balkan11_trapezoid) C++17
0 / 100
144 ms 7796 KB
#include <bits/stdc++.h>
using namespace std; using ii = pair<int,int>; using ll = long long;
void o_o(){ cerr << endl; }
template <class H, class...T> void o_o(H h,T...t) { cerr << ' ' << h; o_o(t...); }
#define debug(...) cerr<<'['<<#__VA_ARGS__<<"]:",o_o(__VA_ARGS__)
#define rep(i,a,b) for (auto i = (a); i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
#define size(x) int((x).size())
#define fi first
#define se second
#define Mup(x,y) x = max(x,y)

const int N = 1e5+3;
int n;
priority_queue<pair<ii,int>,vector<pair<ii,int>>,less<>> pq;
struct segment_tree {
    int t[2*N], c[2*N];
    void update(int k, int v) {
        for (t[k += N] = v; (k /= 2) >= 1;) {
            // if (t[2*k] < t[2*k+1]) c[k] = c[2*k+1];
            // else if (t[2*k] > t[2*k+1]) c[k] = c[2*k];
            // else c[k] = c[2*k]+c[2*k+1];
            t[k] = max(t[2*k],t[2*k+1]);
        }
    }
    int query(int a, int b) {
        int r = 0;
        for (a += N, b += N; a <= b; ++a /= 2, --b /= 2) {
            if (a&1) r = max(r,t[a]);
            if (~b&1) r = max(r,t[b]);
        }
        return r;
    }
} ds;
pair<ii,ii> t[N];

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    vector<int> xs, ys;
    rep(i,1,n) {
        cin >> t[i].fi.fi >> t[i].se.fi;
        xs.push_back(t[i].fi.fi), xs.push_back(t[i].se.fi);
        cin >> t[i].fi.se >> t[i].se.se;
        ys.push_back(t[i].fi.se), ys.push_back(t[i].se.se);
    }
    sort(all(xs)), xs.erase(unique(all(xs)),end(xs));
    sort(all(ys)), ys.erase(unique(all(ys)),end(ys));
    rep(i,1,n) {
        t[i].fi.fi = lower_bound(all(xs),t[i].fi.fi)-begin(xs);
        t[i].fi.se = lower_bound(all(ys),t[i].fi.se)-begin(ys);
        t[i].se.fi = lower_bound(all(xs),t[i].se.fi)-begin(xs);
        t[i].se.se = lower_bound(all(ys),t[i].se.se)-begin(ys);
    }
    sort(t+1,t+n+1);
    int answer = 0;
    rep(i,1,n) {
        auto [p1,p2] = t[i];
        while (not empty(pq) and pq.top().fi.fi < p1.fi) {
            ds.update(pq.top().fi.se,pq.top().se);
            pq.pop();
        }
        int v = ds.query(1,p1.se)+1;
        answer = max(answer,v);
        pq.push({p2,v});
    }
    cout << answer;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Unexpected end of file - int32 expected
2 Incorrect 1 ms 340 KB Unexpected end of file - int32 expected
3 Incorrect 1 ms 340 KB Unexpected end of file - int32 expected
4 Incorrect 2 ms 340 KB Unexpected end of file - int32 expected
5 Incorrect 2 ms 468 KB Unexpected end of file - int32 expected
6 Incorrect 4 ms 596 KB Unexpected end of file - int32 expected
7 Incorrect 4 ms 596 KB Unexpected end of file - int32 expected
8 Incorrect 6 ms 724 KB Unexpected end of file - int32 expected
9 Incorrect 11 ms 1172 KB Unexpected end of file - int32 expected
10 Incorrect 24 ms 1992 KB Unexpected end of file - int32 expected
11 Incorrect 32 ms 2580 KB Unexpected end of file - int32 expected
12 Incorrect 72 ms 4864 KB Unexpected end of file - int32 expected
13 Incorrect 77 ms 4928 KB Unexpected end of file - int32 expected
14 Incorrect 86 ms 6588 KB Unexpected end of file - int32 expected
15 Incorrect 94 ms 6800 KB Unexpected end of file - int32 expected
16 Incorrect 106 ms 6952 KB Unexpected end of file - int32 expected
17 Incorrect 105 ms 7112 KB Unexpected end of file - int32 expected
18 Incorrect 105 ms 7300 KB Unexpected end of file - int32 expected
19 Incorrect 144 ms 6788 KB Unexpected end of file - int32 expected
20 Incorrect 125 ms 7796 KB Unexpected end of file - int32 expected