# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
558427 |
2022-05-07T09:55:02 Z |
hoanghq2004 |
Boat (APIO16_boat) |
C++14 |
|
4 ms |
4564 KB |
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 510;
const int mod = 1e9 + 7;
int n, f[N][N], g[N][N], C[N][N];
int L[N], R[N];
void add(int& a, int b) {
a += b;
if (a >= mod) a -= mod;
}
int main() {
ios :: sync_with_stdio(0); cin.tie(0);
cin >> n;
vector <int> dta = {0};
for (int i = 1; i <= n; ++i) {
cin >> L[i] >> R[i];
--L[i];
dta.push_back(L[i]), dta.push_back(R[i]);
}
sort(dta.begin(), dta.end());
dta.erase(unique(dta.begin(), dta.end()), dta.end());
int m = dta.size();
C[0][0] = 1;
for (int i = 1; i < N; ++i) {
C[i][0] = 1;
for (int j = 1; j <= i; ++j)
C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
}
for (int i = 0; i <= n; ++i) f[i][0] = 1;
for (int s = 1; s < m; ++s) {
int d = dta[s] - dta[s - 1];
for (int i = 0; i <= n; ++i) {
for (int j = 0; j <= i; ++j) {
g[s][i] = 1LL * C[i][j] * C[d][j] % mod;
}
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j < m; ++j) {
f[i][j] = f[i][j - 1];
int cnt = 0;
for (int k = i; k > 0; --k) {
cnt += (L[k] < dta[j] && dta[j] <= R[k]);
add(f[i][j], 1LL * f[k - 1][j - 1] * g[j][cnt] % mod);
}
}
}
cout << f[n][m - 1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
4564 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
4564 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
2888 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
4564 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |