# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404448 | 2021-05-14T12:19:21 Z | CursedCode | Boat (APIO16_boat) | C++14 | 563 ms | 4392 KB |
#include <stdio.h> #include <map> using namespace std; const long long mod = 1000000007; int inv[505]; int N,A[505],B[505],L[1005]; long long D[505][1005]; int main() { inv[1] = 1; for (int i=2;i<505;i++) inv[i] = (mod - mod / i) * inv[mod % i] % mod; scanf ("%d",&N); map<int, int> chk; for (int i=1;i<=N;i++){ scanf ("%d %d",&A[i],&B[i]); chk[A[i]] = chk[B[i]+1] = 0; } int c = 0, last = 0; for (auto &p : chk){ L[c] = p.first - last; p.second = c++; last = p.first; } c--; for (int j=0;j<=c;j++) D[0][j] = 1; for (int i=1;i<=N;i++){ A[i] = chk[A[i]] + 1; B[i] = chk[B[i]+1]; D[i][0] = 1; for (int j=A[i];j<=B[i];j++){ D[i][j] = (D[i][j] + L[j] * D[i-1][j-1]) % mod; long long comb = L[j] - 1; int c = 1; for (int k=i-1;k>0;k--){ if (A[k] <= j && j <= B[k]){ comb = comb * (L[j] - 1 + c) % mod; if (!comb) break; comb = comb * inv[++c] % mod; D[i][j] = (D[i][j] + comb * D[k-1][j-1]) % mod; } } } for (int j=1;j<=c;j++){ D[i][j] = (D[i][j] + D[i][j-1] + D[i-1][j] - D[i-1][j-1] + mod) % mod; } } long long ans = 0; printf ("%lld\n",(D[N][c]+mod-1)%mod); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 4280 KB | Output is correct |
2 | Correct | 9 ms | 4172 KB | Output is correct |
3 | Correct | 9 ms | 4172 KB | Output is correct |
4 | Correct | 10 ms | 4172 KB | Output is correct |
5 | Correct | 8 ms | 4172 KB | Output is correct |
6 | Correct | 8 ms | 4248 KB | Output is correct |
7 | Correct | 8 ms | 4172 KB | Output is correct |
8 | Correct | 9 ms | 4176 KB | Output is correct |
9 | Correct | 9 ms | 4168 KB | Output is correct |
10 | Correct | 9 ms | 4260 KB | Output is correct |
11 | Correct | 8 ms | 4172 KB | Output is correct |
12 | Correct | 8 ms | 4172 KB | Output is correct |
13 | Correct | 9 ms | 4232 KB | Output is correct |
14 | Correct | 8 ms | 4172 KB | Output is correct |
15 | Correct | 9 ms | 4172 KB | Output is correct |
16 | Correct | 3 ms | 2892 KB | Output is correct |
17 | Correct | 3 ms | 3020 KB | Output is correct |
18 | Correct | 3 ms | 2960 KB | Output is correct |
19 | Correct | 3 ms | 3020 KB | Output is correct |
20 | Correct | 3 ms | 3020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 4280 KB | Output is correct |
2 | Correct | 9 ms | 4172 KB | Output is correct |
3 | Correct | 9 ms | 4172 KB | Output is correct |
4 | Correct | 10 ms | 4172 KB | Output is correct |
5 | Correct | 8 ms | 4172 KB | Output is correct |
6 | Correct | 8 ms | 4248 KB | Output is correct |
7 | Correct | 8 ms | 4172 KB | Output is correct |
8 | Correct | 9 ms | 4176 KB | Output is correct |
9 | Correct | 9 ms | 4168 KB | Output is correct |
10 | Correct | 9 ms | 4260 KB | Output is correct |
11 | Correct | 8 ms | 4172 KB | Output is correct |
12 | Correct | 8 ms | 4172 KB | Output is correct |
13 | Correct | 9 ms | 4232 KB | Output is correct |
14 | Correct | 8 ms | 4172 KB | Output is correct |
15 | Correct | 9 ms | 4172 KB | Output is correct |
16 | Correct | 3 ms | 2892 KB | Output is correct |
17 | Correct | 3 ms | 3020 KB | Output is correct |
18 | Correct | 3 ms | 2960 KB | Output is correct |
19 | Correct | 3 ms | 3020 KB | Output is correct |
20 | Correct | 3 ms | 3020 KB | Output is correct |
21 | Correct | 181 ms | 4208 KB | Output is correct |
22 | Correct | 174 ms | 4192 KB | Output is correct |
23 | Correct | 158 ms | 4244 KB | Output is correct |
24 | Correct | 177 ms | 4164 KB | Output is correct |
25 | Correct | 179 ms | 4236 KB | Output is correct |
26 | Correct | 371 ms | 4164 KB | Output is correct |
27 | Correct | 375 ms | 4372 KB | Output is correct |
28 | Correct | 389 ms | 4256 KB | Output is correct |
29 | Correct | 401 ms | 4204 KB | Output is correct |
30 | Correct | 8 ms | 4172 KB | Output is correct |
31 | Correct | 8 ms | 4300 KB | Output is correct |
32 | Correct | 8 ms | 4172 KB | Output is correct |
33 | Correct | 8 ms | 4212 KB | Output is correct |
34 | Correct | 8 ms | 4280 KB | Output is correct |
35 | Correct | 8 ms | 4172 KB | Output is correct |
36 | Correct | 9 ms | 4260 KB | Output is correct |
37 | Correct | 9 ms | 4268 KB | Output is correct |
38 | Correct | 9 ms | 4172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 844 KB | Output is correct |
2 | Correct | 2 ms | 844 KB | Output is correct |
3 | Correct | 3 ms | 844 KB | Output is correct |
4 | Correct | 3 ms | 844 KB | Output is correct |
5 | Correct | 3 ms | 844 KB | Output is correct |
6 | Correct | 5 ms | 844 KB | Output is correct |
7 | Correct | 6 ms | 776 KB | Output is correct |
8 | Correct | 5 ms | 844 KB | Output is correct |
9 | Correct | 7 ms | 788 KB | Output is correct |
10 | Correct | 5 ms | 844 KB | Output is correct |
11 | Correct | 3 ms | 844 KB | Output is correct |
12 | Correct | 3 ms | 844 KB | Output is correct |
13 | Correct | 3 ms | 844 KB | Output is correct |
14 | Correct | 3 ms | 844 KB | Output is correct |
15 | Correct | 3 ms | 844 KB | Output is correct |
16 | Correct | 2 ms | 716 KB | Output is correct |
17 | Correct | 2 ms | 716 KB | Output is correct |
18 | Correct | 2 ms | 716 KB | Output is correct |
19 | Correct | 2 ms | 716 KB | Output is correct |
20 | Correct | 2 ms | 716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 4280 KB | Output is correct |
2 | Correct | 9 ms | 4172 KB | Output is correct |
3 | Correct | 9 ms | 4172 KB | Output is correct |
4 | Correct | 10 ms | 4172 KB | Output is correct |
5 | Correct | 8 ms | 4172 KB | Output is correct |
6 | Correct | 8 ms | 4248 KB | Output is correct |
7 | Correct | 8 ms | 4172 KB | Output is correct |
8 | Correct | 9 ms | 4176 KB | Output is correct |
9 | Correct | 9 ms | 4168 KB | Output is correct |
10 | Correct | 9 ms | 4260 KB | Output is correct |
11 | Correct | 8 ms | 4172 KB | Output is correct |
12 | Correct | 8 ms | 4172 KB | Output is correct |
13 | Correct | 9 ms | 4232 KB | Output is correct |
14 | Correct | 8 ms | 4172 KB | Output is correct |
15 | Correct | 9 ms | 4172 KB | Output is correct |
16 | Correct | 3 ms | 2892 KB | Output is correct |
17 | Correct | 3 ms | 3020 KB | Output is correct |
18 | Correct | 3 ms | 2960 KB | Output is correct |
19 | Correct | 3 ms | 3020 KB | Output is correct |
20 | Correct | 3 ms | 3020 KB | Output is correct |
21 | Correct | 181 ms | 4208 KB | Output is correct |
22 | Correct | 174 ms | 4192 KB | Output is correct |
23 | Correct | 158 ms | 4244 KB | Output is correct |
24 | Correct | 177 ms | 4164 KB | Output is correct |
25 | Correct | 179 ms | 4236 KB | Output is correct |
26 | Correct | 371 ms | 4164 KB | Output is correct |
27 | Correct | 375 ms | 4372 KB | Output is correct |
28 | Correct | 389 ms | 4256 KB | Output is correct |
29 | Correct | 401 ms | 4204 KB | Output is correct |
30 | Correct | 8 ms | 4172 KB | Output is correct |
31 | Correct | 8 ms | 4300 KB | Output is correct |
32 | Correct | 8 ms | 4172 KB | Output is correct |
33 | Correct | 8 ms | 4212 KB | Output is correct |
34 | Correct | 8 ms | 4280 KB | Output is correct |
35 | Correct | 8 ms | 4172 KB | Output is correct |
36 | Correct | 9 ms | 4260 KB | Output is correct |
37 | Correct | 9 ms | 4268 KB | Output is correct |
38 | Correct | 9 ms | 4172 KB | Output is correct |
39 | Correct | 3 ms | 844 KB | Output is correct |
40 | Correct | 2 ms | 844 KB | Output is correct |
41 | Correct | 3 ms | 844 KB | Output is correct |
42 | Correct | 3 ms | 844 KB | Output is correct |
43 | Correct | 3 ms | 844 KB | Output is correct |
44 | Correct | 5 ms | 844 KB | Output is correct |
45 | Correct | 6 ms | 776 KB | Output is correct |
46 | Correct | 5 ms | 844 KB | Output is correct |
47 | Correct | 7 ms | 788 KB | Output is correct |
48 | Correct | 5 ms | 844 KB | Output is correct |
49 | Correct | 3 ms | 844 KB | Output is correct |
50 | Correct | 3 ms | 844 KB | Output is correct |
51 | Correct | 3 ms | 844 KB | Output is correct |
52 | Correct | 3 ms | 844 KB | Output is correct |
53 | Correct | 3 ms | 844 KB | Output is correct |
54 | Correct | 2 ms | 716 KB | Output is correct |
55 | Correct | 2 ms | 716 KB | Output is correct |
56 | Correct | 2 ms | 716 KB | Output is correct |
57 | Correct | 2 ms | 716 KB | Output is correct |
58 | Correct | 2 ms | 716 KB | Output is correct |
59 | Correct | 250 ms | 4376 KB | Output is correct |
60 | Correct | 214 ms | 4212 KB | Output is correct |
61 | Correct | 202 ms | 4164 KB | Output is correct |
62 | Correct | 243 ms | 4324 KB | Output is correct |
63 | Correct | 238 ms | 4208 KB | Output is correct |
64 | Correct | 554 ms | 4284 KB | Output is correct |
65 | Correct | 548 ms | 4256 KB | Output is correct |
66 | Correct | 550 ms | 4332 KB | Output is correct |
67 | Correct | 553 ms | 4392 KB | Output is correct |
68 | Correct | 563 ms | 4172 KB | Output is correct |
69 | Correct | 209 ms | 4236 KB | Output is correct |
70 | Correct | 208 ms | 4204 KB | Output is correct |
71 | Correct | 208 ms | 4240 KB | Output is correct |
72 | Correct | 225 ms | 4256 KB | Output is correct |
73 | Correct | 223 ms | 4248 KB | Output is correct |
74 | Correct | 28 ms | 2940 KB | Output is correct |
75 | Correct | 26 ms | 2924 KB | Output is correct |
76 | Correct | 27 ms | 3048 KB | Output is correct |
77 | Correct | 27 ms | 3012 KB | Output is correct |
78 | Correct | 31 ms | 3092 KB | Output is correct |