#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) {
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 |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Incorrect |
8 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
11 ms |
384 KB |
Output isn't correct |
7 |
Correct |
16 ms |
512 KB |
Output is correct |
8 |
Incorrect |
30 ms |
512 KB |
Output isn't correct |
9 |
Runtime error |
4 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
4 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
16 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |