# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
967192 | Roman70 | trapezoid (balkan11_trapezoid) | C++17 | 1067 ms | 3816 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>
#define ll long long
using namespace std;
struct trapezoid{
ll a,b,c,d;
};
bool cmp(trapezoid &a, trapezoid &b){
return a.a < b.a;
}
const int sz = 1e5+1;
int dp[sz];
int dp2[sz];
const int mod = 30013;
int main()
{
int n;
cin >> n;
trapezoid a[n];
for(int i = 0 ;i<n;i++){
cin >> a[i].a >> a[i].b >> a[i].c >> a[i].d;
}
sort(a,a+n,cmp);
int ans = 0;
map<int,int>cnt;
for(int i = n-1;i>=0;i--){
dp[i] = 1;
for(int j = i;j<n;j++){
if(a[i].b < a[j].a && a[i].d < a[j].c) dp[i] = max(dp[i],dp[j]+1);
}
ans = max(ans,dp[i]);
}
ll ans2 = 0;
for(int i =0;i<n;i++) if(dp[i] == 1) dp2[i] = 1;
for(int i = n-1; i >= 0; i--){
for(int j = i+1;j<n;j++){
if(a[i].b < a[j].a && a[i].d < a[j].c && dp[j] == dp[i]-1) dp2[i] = (dp2[i] + dp2[j]) % mod;
}
if(dp[i] == ans) ans2 = (ans2 + dp2[i]) % mod;
}
cout<<ans<<" "<<ans2;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |