# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143461 | 2019-08-14T06:50:00 Z | HellAngel | Boat (APIO16_boat) | C++14 | 816 ms | 20316 KB |
#include <bits/stdc++.h> #define int long long using namespace std; const int maxn = 1007; const int somod = 1e9 + 7; int n, m, a[maxn], b[maxn]; int precal[maxn][maxn], precal2[maxn][maxn], s[maxn][maxn], cnt[maxn]; vector<int> vt; int BIT[maxn], ans[maxn], dp[maxn][maxn], total[maxn]; int Pow(int i, int j) { if(j == 0) return 1; int mid = Pow(i, j / 2); mid = mid * mid % somod; if(j & 1) mid = mid * i % somod; return mid; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout); cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; vt.push_back(a[i]); vt.push_back(b[i] + 1); } sort(vt.begin(), vt.end()); vt.erase(unique(vt.begin(), vt.end()), vt.end()); int k = vt.size(); k--; for(int i = 1; i <= k; i++) { precal[i][0] = 1; int Dist = vt[i] - vt[i - 1]; precal[i][1] = Dist; for(int j = 2; j <= n + 1; j++) { precal[i][j] = precal[i][j - 1] * (Dist + j - 1) % somod * Pow(j, somod - 2) % somod; ///figurate number } } for(int i = 1; i <= k; i++) { int Dist = vt[i] - vt[i - 1] - 1; precal2[i][1] = Dist; for(int j = 2; j <= n + 1; j++) { precal2[i][j] = precal2[i][j - 1] * (Dist + j - 1) % somod * Pow(j, somod - 2) % somod; ///figurate number } } for(int i = 1; i <= n; i++) { int sum = 0; for(int j = 1; j <= k; j++) { int sum = 0, dem = 1; int gau = precal[j][dem]; if(a[i] <= vt[j - 1] && vt[j] - 1 <= b[i]) { cnt[j]++; for(int t = i - 1; t >= 1; t--) { sum = (sum + gau * s[t][j - 1]) % somod; if(a[t] <= vt[j - 1] && vt[j] - 1 <= b[t]) gau = (gau + precal2[j][++dem]) % somod; } sum = (sum + precal[j][cnt[j]]) % somod; } s[i][j] = (s[i][j - 1] + sum) % somod; } } int ans = 0; for(int i = 1; i <= n; i++) ans = (ans + s[i][k]) % somod; cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 347 ms | 20216 KB | Output is correct |
2 | Correct | 344 ms | 20272 KB | Output is correct |
3 | Correct | 339 ms | 20220 KB | Output is correct |
4 | Correct | 339 ms | 20044 KB | Output is correct |
5 | Correct | 339 ms | 20088 KB | Output is correct |
6 | Correct | 339 ms | 20228 KB | Output is correct |
7 | Correct | 339 ms | 20088 KB | Output is correct |
8 | Correct | 339 ms | 20088 KB | Output is correct |
9 | Correct | 339 ms | 20196 KB | Output is correct |
10 | Correct | 343 ms | 20088 KB | Output is correct |
11 | Correct | 339 ms | 20160 KB | Output is correct |
12 | Correct | 338 ms | 20120 KB | Output is correct |
13 | Correct | 342 ms | 20216 KB | Output is correct |
14 | Correct | 344 ms | 20232 KB | Output is correct |
15 | Correct | 339 ms | 20060 KB | Output is correct |
16 | Correct | 65 ms | 5880 KB | Output is correct |
17 | Correct | 69 ms | 6328 KB | Output is correct |
18 | Correct | 67 ms | 6136 KB | Output is correct |
19 | Correct | 70 ms | 6108 KB | Output is correct |
20 | Correct | 68 ms | 6008 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 347 ms | 20216 KB | Output is correct |
2 | Correct | 344 ms | 20272 KB | Output is correct |
3 | Correct | 339 ms | 20220 KB | Output is correct |
4 | Correct | 339 ms | 20044 KB | Output is correct |
5 | Correct | 339 ms | 20088 KB | Output is correct |
6 | Correct | 339 ms | 20228 KB | Output is correct |
7 | Correct | 339 ms | 20088 KB | Output is correct |
8 | Correct | 339 ms | 20088 KB | Output is correct |
9 | Correct | 339 ms | 20196 KB | Output is correct |
10 | Correct | 343 ms | 20088 KB | Output is correct |
11 | Correct | 339 ms | 20160 KB | Output is correct |
12 | Correct | 338 ms | 20120 KB | Output is correct |
13 | Correct | 342 ms | 20216 KB | Output is correct |
14 | Correct | 344 ms | 20232 KB | Output is correct |
15 | Correct | 339 ms | 20060 KB | Output is correct |
16 | Correct | 65 ms | 5880 KB | Output is correct |
17 | Correct | 69 ms | 6328 KB | Output is correct |
18 | Correct | 67 ms | 6136 KB | Output is correct |
19 | Correct | 70 ms | 6108 KB | Output is correct |
20 | Correct | 68 ms | 6008 KB | Output is correct |
21 | Correct | 625 ms | 18820 KB | Output is correct |
22 | Correct | 617 ms | 19064 KB | Output is correct |
23 | Correct | 610 ms | 18680 KB | Output is correct |
24 | Correct | 616 ms | 18628 KB | Output is correct |
25 | Correct | 620 ms | 18680 KB | Output is correct |
26 | Correct | 697 ms | 18296 KB | Output is correct |
27 | Correct | 712 ms | 18532 KB | Output is correct |
28 | Correct | 693 ms | 18296 KB | Output is correct |
29 | Correct | 750 ms | 18172 KB | Output is correct |
30 | Correct | 340 ms | 20088 KB | Output is correct |
31 | Correct | 340 ms | 20204 KB | Output is correct |
32 | Correct | 340 ms | 20216 KB | Output is correct |
33 | Correct | 341 ms | 20216 KB | Output is correct |
34 | Correct | 346 ms | 20204 KB | Output is correct |
35 | Correct | 341 ms | 20088 KB | Output is correct |
36 | Correct | 341 ms | 20088 KB | Output is correct |
37 | Correct | 339 ms | 20188 KB | Output is correct |
38 | Correct | 341 ms | 20144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 2808 KB | Output is correct |
2 | Correct | 19 ms | 2808 KB | Output is correct |
3 | Correct | 20 ms | 2928 KB | Output is correct |
4 | Correct | 19 ms | 2808 KB | Output is correct |
5 | Correct | 19 ms | 2808 KB | Output is correct |
6 | Correct | 20 ms | 2808 KB | Output is correct |
7 | Correct | 22 ms | 2780 KB | Output is correct |
8 | Correct | 20 ms | 2808 KB | Output is correct |
9 | Correct | 20 ms | 2808 KB | Output is correct |
10 | Correct | 21 ms | 2808 KB | Output is correct |
11 | Correct | 19 ms | 2808 KB | Output is correct |
12 | Correct | 19 ms | 2780 KB | Output is correct |
13 | Correct | 19 ms | 2808 KB | Output is correct |
14 | Correct | 19 ms | 2936 KB | Output is correct |
15 | Correct | 19 ms | 2808 KB | Output is correct |
16 | Correct | 12 ms | 2012 KB | Output is correct |
17 | Correct | 12 ms | 1912 KB | Output is correct |
18 | Correct | 12 ms | 1912 KB | Output is correct |
19 | Correct | 12 ms | 1912 KB | Output is correct |
20 | Correct | 12 ms | 1912 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 347 ms | 20216 KB | Output is correct |
2 | Correct | 344 ms | 20272 KB | Output is correct |
3 | Correct | 339 ms | 20220 KB | Output is correct |
4 | Correct | 339 ms | 20044 KB | Output is correct |
5 | Correct | 339 ms | 20088 KB | Output is correct |
6 | Correct | 339 ms | 20228 KB | Output is correct |
7 | Correct | 339 ms | 20088 KB | Output is correct |
8 | Correct | 339 ms | 20088 KB | Output is correct |
9 | Correct | 339 ms | 20196 KB | Output is correct |
10 | Correct | 343 ms | 20088 KB | Output is correct |
11 | Correct | 339 ms | 20160 KB | Output is correct |
12 | Correct | 338 ms | 20120 KB | Output is correct |
13 | Correct | 342 ms | 20216 KB | Output is correct |
14 | Correct | 344 ms | 20232 KB | Output is correct |
15 | Correct | 339 ms | 20060 KB | Output is correct |
16 | Correct | 65 ms | 5880 KB | Output is correct |
17 | Correct | 69 ms | 6328 KB | Output is correct |
18 | Correct | 67 ms | 6136 KB | Output is correct |
19 | Correct | 70 ms | 6108 KB | Output is correct |
20 | Correct | 68 ms | 6008 KB | Output is correct |
21 | Correct | 625 ms | 18820 KB | Output is correct |
22 | Correct | 617 ms | 19064 KB | Output is correct |
23 | Correct | 610 ms | 18680 KB | Output is correct |
24 | Correct | 616 ms | 18628 KB | Output is correct |
25 | Correct | 620 ms | 18680 KB | Output is correct |
26 | Correct | 697 ms | 18296 KB | Output is correct |
27 | Correct | 712 ms | 18532 KB | Output is correct |
28 | Correct | 693 ms | 18296 KB | Output is correct |
29 | Correct | 750 ms | 18172 KB | Output is correct |
30 | Correct | 340 ms | 20088 KB | Output is correct |
31 | Correct | 340 ms | 20204 KB | Output is correct |
32 | Correct | 340 ms | 20216 KB | Output is correct |
33 | Correct | 341 ms | 20216 KB | Output is correct |
34 | Correct | 346 ms | 20204 KB | Output is correct |
35 | Correct | 341 ms | 20088 KB | Output is correct |
36 | Correct | 341 ms | 20088 KB | Output is correct |
37 | Correct | 339 ms | 20188 KB | Output is correct |
38 | Correct | 341 ms | 20144 KB | Output is correct |
39 | Correct | 19 ms | 2808 KB | Output is correct |
40 | Correct | 19 ms | 2808 KB | Output is correct |
41 | Correct | 20 ms | 2928 KB | Output is correct |
42 | Correct | 19 ms | 2808 KB | Output is correct |
43 | Correct | 19 ms | 2808 KB | Output is correct |
44 | Correct | 20 ms | 2808 KB | Output is correct |
45 | Correct | 22 ms | 2780 KB | Output is correct |
46 | Correct | 20 ms | 2808 KB | Output is correct |
47 | Correct | 20 ms | 2808 KB | Output is correct |
48 | Correct | 21 ms | 2808 KB | Output is correct |
49 | Correct | 19 ms | 2808 KB | Output is correct |
50 | Correct | 19 ms | 2780 KB | Output is correct |
51 | Correct | 19 ms | 2808 KB | Output is correct |
52 | Correct | 19 ms | 2936 KB | Output is correct |
53 | Correct | 19 ms | 2808 KB | Output is correct |
54 | Correct | 12 ms | 2012 KB | Output is correct |
55 | Correct | 12 ms | 1912 KB | Output is correct |
56 | Correct | 12 ms | 1912 KB | Output is correct |
57 | Correct | 12 ms | 1912 KB | Output is correct |
58 | Correct | 12 ms | 1912 KB | Output is correct |
59 | Correct | 668 ms | 20240 KB | Output is correct |
60 | Correct | 662 ms | 20248 KB | Output is correct |
61 | Correct | 644 ms | 20216 KB | Output is correct |
62 | Correct | 668 ms | 20216 KB | Output is correct |
63 | Correct | 656 ms | 20216 KB | Output is correct |
64 | Correct | 798 ms | 20316 KB | Output is correct |
65 | Correct | 816 ms | 20216 KB | Output is correct |
66 | Correct | 799 ms | 20216 KB | Output is correct |
67 | Correct | 811 ms | 20268 KB | Output is correct |
68 | Correct | 795 ms | 20216 KB | Output is correct |
69 | Correct | 573 ms | 20216 KB | Output is correct |
70 | Correct | 578 ms | 20148 KB | Output is correct |
71 | Correct | 582 ms | 20216 KB | Output is correct |
72 | Correct | 575 ms | 20144 KB | Output is correct |
73 | Correct | 579 ms | 20216 KB | Output is correct |
74 | Correct | 123 ms | 6008 KB | Output is correct |
75 | Correct | 121 ms | 6008 KB | Output is correct |
76 | Correct | 125 ms | 6116 KB | Output is correct |
77 | Correct | 124 ms | 6032 KB | Output is correct |
78 | Correct | 123 ms | 5980 KB | Output is correct |