# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125667 | faustaadp | trapezoid (balkan11_trapezoid) | C++17 | 299 ms | 65540 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>
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;
vector<int> v[101010];
pair<pair<int,int>,pair<int,int> > A[101010];
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];
}
ll depe2(ll 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];
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(i=1;i<=n;i++)
{
cin>>ta>>tb>>tc>>td;
A[i]=mp(mp(ta,tb),mp(tc,td));
}
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+=depe2(i);
cout<<h1<<" "<<h2<<"\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |