#include <bits/stdc++.h>
using namespace std;
#define file "test"
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
const int N=1e5+2, INF=1e6;
int n,a[N],b[N],c[N],d[N],bit[INF+2],res,f[N];
vector<int> v;
struct hihi
{
int x,y,id;
bool operator < (const hihi &o) const
{
if (x!=o.x) return x < o.x; else return id > o.id;
}
};
vector<hihi> event;
void update(int x, int val)
{
for (; x<=INF; x+=x&-x) bit[x]=max(bit[x], val);
}
int get(int x)
{
int res=0; for (; x>0; x-=x&-x) res=max(res, bit[x]);
return res;
}
int main()
{
//freopen(file".inp", "r", stdin);
//freopen(file".out", "w", stdout);
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n;
for (int i=1;i<=n;i++)
{
cin>>a[i]>>b[i]>>c[i]>>d[i];
v.pb(a[i]); v.pb(b[i]); v.pb(c[i]); v.pb(d[i]);
}
for (int i=1;i<=n;i++)
{
a[i] = lower_bound(all(v), a[i]) - v.begin()+1;
b[i] = lower_bound(all(v), b[i]) - v.begin()+1;
c[i] = lower_bound(all(v), c[i]) - v.begin()+1;
d[i] = lower_bound(all(v), d[i]) - v.begin()+1;
event.pb({a[i], c[i], i});
event.pb({b[i], d[i], -i});
}
sort(all(event));
for (hihi e : event)
{
int x=e.x, y=e.y;
if (e.id > 0)
{
f[e.id] = get(y-1) + 1;
res=max(res, f[e.id]);
}
else update(y, f[-e.id]);
}
cout<<res;
}
Compilation message
trapezoid.cpp: In function 'int main()':
trapezoid.cpp:61:13: warning: unused variable 'x' [-Wunused-variable]
61 | int x=e.x, y=e.y;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
1 ms |
336 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
1 ms |
592 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
2 ms |
592 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
3 ms |
592 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
3 ms |
848 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
3 ms |
848 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
5 ms |
1104 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
8 ms |
1428 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
12 ms |
2768 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
14 ms |
3148 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
25 ms |
5636 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
34 ms |
6600 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
37 ms |
10580 KB |
Unexpected end of file - int32 expected |
15 |
Incorrect |
45 ms |
10844 KB |
Unexpected end of file - int32 expected |
16 |
Incorrect |
48 ms |
10976 KB |
Unexpected end of file - int32 expected |
17 |
Incorrect |
70 ms |
11076 KB |
Unexpected end of file - int32 expected |
18 |
Incorrect |
50 ms |
11336 KB |
Unexpected end of file - int32 expected |
19 |
Incorrect |
60 ms |
11512 KB |
Unexpected end of file - int32 expected |
20 |
Incorrect |
66 ms |
11712 KB |
Unexpected end of file - int32 expected |