Submission #202582

# Submission time Handle Problem Language Result Execution time Memory
202582 2020-02-17T07:16:40 Z pr3pony Boat (APIO16_boat) C++14
9 / 100
14 ms 8444 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 505, MOD = 1e9 + 7;
typedef long long ll;
vector<int> val;
typedef array<int, 2> ar;
ar p[N];
ll dp[N][2 * N], su[N][2 * N], inv[N];
int main()
{
    int n;
    cin >> n;
    val = {-1};
    for (int i = 1; i <= n; ++i) {
        cin >> p[i][0] >> p[i][1];
        ++p[i][1];
        val.push_back(p[i][0]);
        val.push_back(p[i][1]);
    }
    sort(val.begin(), val.end());
    val.resize(unique(val.begin(), val.end()) - val.begin());
    int w = val.size();

    inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;

    dp[0][0] = 1;
    fill_n(su[0], w, 1);
    for (int b = 1; b <= n; ++b) {
        copy_n(dp[b - 1], w, dp[b]);
        for (int i = w - 1; i > 0; --i) {
            ll cn = val[i] - val[i - 1];
            ll cj = cn;
            for (int j = 1, o = b; j <= b && p[o][0] <= val[i - 1] && val[i] <= p[o][1]; ++j, --o) {
                //dp[b][i] += c(val[i] - val[i - 1], j) * su[o - 1][i - 1]
                (dp[b][i] += cj * su[o - 1][i - 1]) %= MOD;
                cj = cj * (cn - j) % MOD * inv[j + 1] % MOD;
            }
        }
        su[b][0] = dp[b][0];
        for (int i = 1; i < w; ++i)
            su[b][i] = (dp[b][i] + su[b][i - 1]) % MOD;
    }

    cout << (su[n][w - 1] + MOD - 1) % MOD << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 8312 KB Output is correct
2 Correct 13 ms 8188 KB Output is correct
3 Correct 13 ms 8312 KB Output is correct
4 Correct 13 ms 8312 KB Output is correct
5 Correct 13 ms 8312 KB Output is correct
6 Correct 12 ms 8444 KB Output is correct
7 Correct 13 ms 8312 KB Output is correct
8 Correct 12 ms 8312 KB Output is correct
9 Correct 12 ms 8312 KB Output is correct
10 Correct 13 ms 8312 KB Output is correct
11 Correct 13 ms 8312 KB Output is correct
12 Correct 12 ms 8312 KB Output is correct
13 Correct 12 ms 8312 KB Output is correct
14 Correct 12 ms 8312 KB Output is correct
15 Correct 13 ms 8312 KB Output is correct
16 Correct 9 ms 5752 KB Output is correct
17 Correct 9 ms 5880 KB Output is correct
18 Correct 8 ms 5756 KB Output is correct
19 Correct 9 ms 5880 KB Output is correct
20 Correct 9 ms 5752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 8312 KB Output is correct
2 Correct 13 ms 8188 KB Output is correct
3 Correct 13 ms 8312 KB Output is correct
4 Correct 13 ms 8312 KB Output is correct
5 Correct 13 ms 8312 KB Output is correct
6 Correct 12 ms 8444 KB Output is correct
7 Correct 13 ms 8312 KB Output is correct
8 Correct 12 ms 8312 KB Output is correct
9 Correct 12 ms 8312 KB Output is correct
10 Correct 13 ms 8312 KB Output is correct
11 Correct 13 ms 8312 KB Output is correct
12 Correct 12 ms 8312 KB Output is correct
13 Correct 12 ms 8312 KB Output is correct
14 Correct 12 ms 8312 KB Output is correct
15 Correct 13 ms 8312 KB Output is correct
16 Correct 9 ms 5752 KB Output is correct
17 Correct 9 ms 5880 KB Output is correct
18 Correct 8 ms 5756 KB Output is correct
19 Correct 9 ms 5880 KB Output is correct
20 Correct 9 ms 5752 KB Output is correct
21 Incorrect 14 ms 8184 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 8312 KB Output is correct
2 Correct 13 ms 8188 KB Output is correct
3 Correct 13 ms 8312 KB Output is correct
4 Correct 13 ms 8312 KB Output is correct
5 Correct 13 ms 8312 KB Output is correct
6 Correct 12 ms 8444 KB Output is correct
7 Correct 13 ms 8312 KB Output is correct
8 Correct 12 ms 8312 KB Output is correct
9 Correct 12 ms 8312 KB Output is correct
10 Correct 13 ms 8312 KB Output is correct
11 Correct 13 ms 8312 KB Output is correct
12 Correct 12 ms 8312 KB Output is correct
13 Correct 12 ms 8312 KB Output is correct
14 Correct 12 ms 8312 KB Output is correct
15 Correct 13 ms 8312 KB Output is correct
16 Correct 9 ms 5752 KB Output is correct
17 Correct 9 ms 5880 KB Output is correct
18 Correct 8 ms 5756 KB Output is correct
19 Correct 9 ms 5880 KB Output is correct
20 Correct 9 ms 5752 KB Output is correct
21 Incorrect 14 ms 8184 KB Output isn't correct
22 Halted 0 ms 0 KB -