#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int n,i,ta,tb,tc,td,j,h1,h2,d[101010],d2[101010],mo=30013,K;
vector<int> v[101010];
pair<pair<int,int>,pair<int,int> > A[101010];
map<int,int> BIT;
int depe(int aa)
{
if(d[aa]==-1)
{
d[aa]=0;
int ii;
for(ii=0;ii<v[aa].size();ii++)
d[aa]=max(d[aa],depe(v[aa][ii]));
d[aa]++;
}
return d[aa];
}
int depe2(int aa)
{
if(depe(aa)==1)return 1;
if(d2[aa]==-1)
{
d2[aa]=0;
int ii;
for(ii=0;ii<v[aa].size();ii++)
if(depe(aa)==depe(v[aa][ii])+1)
d2[aa]=(d2[aa]+depe2(v[aa][ii]))%mo;
}
return d2[aa];
}
void upd(int aa,int bb)
{
int ii;
for(ii=aa;ii<=K;ii+=(ii&(-ii)))
BIT[ii]=max(BIT[ii],bb);
}
int que(int aa)
{
int ii,H=0;
for(ii=aa;ii>=1;ii-=(ii&(-ii)))
H=max(H,BIT[ii]);
return H;
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
K=1000000001;
cin>>n;
for(i=1;i<=n;i++)
{
cin>>ta>>tb>>tc>>td;
A[i]=mp(mp(ta,tb),mp(tc,td));
}
if(1)
{
sort(A+1,A+1+n);
for(i=1;i<=n;i++)
{
int L=i+1,R=n,C,H=0;
while(L<=R)
{
C=(L+R)/2;
if(A[i].fi.se<A[C].fi.fi)
{
H=i;
R=C-1;
}
else
L=C+1;
}
if(H)
v[H].pb(i);
}
//return 0;
for(i=n;i>=1;i--)
{
for(j=0;j<v[i].size();j++)
{
int now=v[i][j];
d[i]=que(A[now].se.se);
}
d[i]++;
upd(A[i].se.fi+1,d[i]);
h1=max(h1,d[i]);
}
//cout<<h1<<"\n";
}
else
{
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(A[i].fi.se<A[j].fi.fi&&A[i].se.se<A[j].se.fi)
v[i].pb(j);
memset(d,-1,sizeof(d));
memset(d2,-1,sizeof(d2));
for(i=1;i<=n;i++)
h1=max(h1,depe(i));
for(i=1;i<=n;i++)
if(depe(i)==h1)
h2=(h2+depe2(i))%mo;
}
cout<<h1<<" "<<h2<<"\n";
}
Compilation message
trapezoid.cpp: In function 'int depe(int)':
trapezoid.cpp:18:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ii=0;ii<v[aa].size();ii++)
~~^~~~~~~~~~~~~
trapezoid.cpp: In function 'int depe2(int)':
trapezoid.cpp:31:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ii=0;ii<v[aa].size();ii++)
~~^~~~~~~~~~~~~
trapezoid.cpp: In function 'int main()':
trapezoid.cpp:83:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(j=0;j<v[i].size();j++)
~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
2808 KB |
Output isn't correct |
2 |
Incorrect |
4 ms |
2680 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
2808 KB |
Output isn't correct |
4 |
Incorrect |
6 ms |
2936 KB |
Output isn't correct |
5 |
Incorrect |
10 ms |
3192 KB |
Output isn't correct |
6 |
Incorrect |
14 ms |
3576 KB |
Output isn't correct |
7 |
Incorrect |
16 ms |
3836 KB |
Output isn't correct |
8 |
Incorrect |
18 ms |
3576 KB |
Output isn't correct |
9 |
Incorrect |
35 ms |
4344 KB |
Output isn't correct |
10 |
Incorrect |
78 ms |
8056 KB |
Output isn't correct |
11 |
Incorrect |
102 ms |
8440 KB |
Output isn't correct |
12 |
Incorrect |
243 ms |
14432 KB |
Output isn't correct |
13 |
Incorrect |
305 ms |
16816 KB |
Output isn't correct |
14 |
Incorrect |
400 ms |
23020 KB |
Output isn't correct |
15 |
Incorrect |
375 ms |
16888 KB |
Output isn't correct |
16 |
Incorrect |
442 ms |
19076 KB |
Output isn't correct |
17 |
Incorrect |
480 ms |
22904 KB |
Output isn't correct |
18 |
Incorrect |
322 ms |
19796 KB |
Output isn't correct |
19 |
Incorrect |
449 ms |
23288 KB |
Output isn't correct |
20 |
Execution timed out |
516 ms |
23288 KB |
Time limit exceeded |