# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
908002 | 12345678 | trapezoid (balkan11_trapezoid) | C++17 | 1076 ms | 5640 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;
const int nx=1e5+5, mod=30013;
struct trapezoid
{
int a=0, b=0, c=0, d=0;
bool operator< (const trapezoid &o) const {
return a<o.a;
}
} s[nx];
int n, dp[nx], cnt[nx], mx, res;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=1; i<=n; i++) cin>>s[i].a>>s[i].b>>s[i].c>>s[i].d;
sort(s+1, s+n+1);
cnt[0]=1;
for (int i=1; i<=n; i++)
{
for (int j=0; j<i; j++)
{
if (s[i].a>s[j].b&&s[i].c>s[j].d)
{
if (dp[j]+1>dp[i]) dp[i]=dp[j]+1, cnt[i]=cnt[j];
else if (dp[j]+1==dp[i]) cnt[i]=(cnt[i]+cnt[j])%mod;
}
}
mx=max(mx, dp[i]);
}
for (int i=1; i<=n; i++) if (dp[i]==mx) res=(res+cnt[i])%mod;
cout<<mx<<' '<<res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |