# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106006 | MrTEK | trapezoid (balkan11_trapezoid) | C++14 | 36 ms | 640 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;
typedef long long int ll;
typedef pair<int,int> ii;
const int N = 5e3 + 5;
const int mod = 30013;
#define ul first.first
#define ur first.second
#define dl second.first
#define dr second.second
pair <ii,ii> a[N];
int n,dp[N],cnt[N],ans,ans2;
int add(int x,int y) {
return x + y >= mod ? x + y - mod : x + y;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n;
assert(n <= 5000);
for (int i = 1 ; i <= n ; i++)
cin >> a[i].ul >> a[i].ur >> a[i].dl >> a[i].dr;
sort(a + 1,a + n + 1);
for (int i = n ; i >= 1 ; i--) {
dp[i] = 1;
cnt[i] = 1;
for (int j = i + 1 ; j <= n ; j++)
if (a[i].dr < a[j].dl && a[i].ur < a[j].ul) {
if (dp[j] + 1 == dp[i])
cnt[i] = add(cnt[i],cnt[j]);
if (dp[j] + 1 > dp[i]) {
dp[i] = dp[j] + 1;
cnt[i] = cnt[j];
}
}
if (ans < dp[i]) {
ans = dp[i];
ans2 = cnt[i];
}
else if(ans == dp[i])
ans2 = add(ans2,cnt[i]);
}
cout << ans << " " << ans2 << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |