# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
106003 | MrTEK | 사다리꼴 (balkan11_trapezoid) | C++14 | 30 ms | 1152 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
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) {
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... |