# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
278535 | 2020-08-21T13:59:29 Z | BeanZ | Boat (APIO16_boat) | C++14 | 879 ms | 4352 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' ll dp[1005][505], inv[2005], l[505], r[505]; ll mod = 1e9 + 7; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("VietCT.INP", "r")){ freopen("VietCT.INP", "r", stdin); freopen("VietCT.OUT", "w", stdout); } ll n; cin >> n; inv[1] = 1; for (int i = 2; i < 2000; i++) inv[i] = (mod / i) * (mod - inv[mod % i]) % mod; vector<ll> val; for (int i = 1; i <= n; i++){ cin >> l[i] >> r[i]; val.push_back(l[i]); r[i]++; val.push_back(r[i]); } sort(val.begin(), val.end()); val.resize(unique(val.begin(), val.end()) - val.begin()); for (int i = 1; i <= n; i++){ l[i] = lower_bound(val.begin(), val.end(), l[i]) - val.begin() + 1; r[i] = lower_bound(val.begin(), val.end(), r[i]) - val.begin() + 1; } dp[0][0] = 1; for (int i = 1; i < val.size(); i++){ dp[i][0] = 1; for (int j = 1; j <= n; j++){ dp[i][j] = dp[i - 1][j]; if (i < l[j] || i >= r[j]) continue; ll s = val[i] - val[i - 1]; ll cnt = 1; ll p = s; for (int k = j - 1; k >= 0; k--){ dp[i][j] = (dp[i][j] + dp[i - 1][k] * p) % mod; p = p * (s + cnt) % mod; p = p * inv[cnt + 1] % mod; cnt++; } } } ll ans = 0; for (int i = 1; i <= n; i++){ ans = (ans + dp[val.size() - 1][i]) % mod; } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4352 KB | Output is correct |
2 | Correct | 6 ms | 4352 KB | Output is correct |
3 | Correct | 6 ms | 4352 KB | Output is correct |
4 | Correct | 6 ms | 4352 KB | Output is correct |
5 | Correct | 6 ms | 4352 KB | Output is correct |
6 | Correct | 5 ms | 4352 KB | Output is correct |
7 | Correct | 5 ms | 4352 KB | Output is correct |
8 | Correct | 6 ms | 4352 KB | Output is correct |
9 | Correct | 6 ms | 4352 KB | Output is correct |
10 | Correct | 5 ms | 4352 KB | Output is correct |
11 | Correct | 5 ms | 4352 KB | Output is correct |
12 | Correct | 5 ms | 4352 KB | Output is correct |
13 | Correct | 5 ms | 4352 KB | Output is correct |
14 | Correct | 5 ms | 4352 KB | Output is correct |
15 | Correct | 5 ms | 4352 KB | Output is correct |
16 | Correct | 3 ms | 1024 KB | Output is correct |
17 | Correct | 3 ms | 1152 KB | Output is correct |
18 | Correct | 4 ms | 1152 KB | Output is correct |
19 | Correct | 3 ms | 1152 KB | Output is correct |
20 | Correct | 4 ms | 1152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4352 KB | Output is correct |
2 | Correct | 6 ms | 4352 KB | Output is correct |
3 | Correct | 6 ms | 4352 KB | Output is correct |
4 | Correct | 6 ms | 4352 KB | Output is correct |
5 | Correct | 6 ms | 4352 KB | Output is correct |
6 | Correct | 5 ms | 4352 KB | Output is correct |
7 | Correct | 5 ms | 4352 KB | Output is correct |
8 | Correct | 6 ms | 4352 KB | Output is correct |
9 | Correct | 6 ms | 4352 KB | Output is correct |
10 | Correct | 5 ms | 4352 KB | Output is correct |
11 | Correct | 5 ms | 4352 KB | Output is correct |
12 | Correct | 5 ms | 4352 KB | Output is correct |
13 | Correct | 5 ms | 4352 KB | Output is correct |
14 | Correct | 5 ms | 4352 KB | Output is correct |
15 | Correct | 5 ms | 4352 KB | Output is correct |
16 | Correct | 3 ms | 1024 KB | Output is correct |
17 | Correct | 3 ms | 1152 KB | Output is correct |
18 | Correct | 4 ms | 1152 KB | Output is correct |
19 | Correct | 3 ms | 1152 KB | Output is correct |
20 | Correct | 4 ms | 1152 KB | Output is correct |
21 | Incorrect | 879 ms | 4028 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 1152 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4352 KB | Output is correct |
2 | Correct | 6 ms | 4352 KB | Output is correct |
3 | Correct | 6 ms | 4352 KB | Output is correct |
4 | Correct | 6 ms | 4352 KB | Output is correct |
5 | Correct | 6 ms | 4352 KB | Output is correct |
6 | Correct | 5 ms | 4352 KB | Output is correct |
7 | Correct | 5 ms | 4352 KB | Output is correct |
8 | Correct | 6 ms | 4352 KB | Output is correct |
9 | Correct | 6 ms | 4352 KB | Output is correct |
10 | Correct | 5 ms | 4352 KB | Output is correct |
11 | Correct | 5 ms | 4352 KB | Output is correct |
12 | Correct | 5 ms | 4352 KB | Output is correct |
13 | Correct | 5 ms | 4352 KB | Output is correct |
14 | Correct | 5 ms | 4352 KB | Output is correct |
15 | Correct | 5 ms | 4352 KB | Output is correct |
16 | Correct | 3 ms | 1024 KB | Output is correct |
17 | Correct | 3 ms | 1152 KB | Output is correct |
18 | Correct | 4 ms | 1152 KB | Output is correct |
19 | Correct | 3 ms | 1152 KB | Output is correct |
20 | Correct | 4 ms | 1152 KB | Output is correct |
21 | Incorrect | 879 ms | 4028 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |