Submission #837386


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <queue>

using namespace std;

#define pb push_back
#define pbk pop_back
#define fs first
#define sc second
#define sz(s) ((int) (s).size())
#define all(x) (x).begin(), (x).end()
#define mt make_tuple
#define mp make_pair
#define next hunext
#define prev huprev

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;

const int inf = 1e9;
const double pi = 4 * atan(1.0);
const double eps = 1e-9;
const int N = 444;
const int MOD = int(1e9) + 7;

int a[N], b[N];
int dp[N][N], sum[N][N], pw[N][N];

inline int get_sum(int x, int l, int r) {
    assert(l <= r);
    int res = sum[x][r] - (l > 0 ? sum[x][l - 1] : 0);
    if (res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
#ifdef LOCAL42
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
    }
    for (int i = 1; i <= n; ++i) {
        scanf("%d", b + i);
    }
    for (int i = 1; i < N; ++i) {
        pw[i][0] = 1;
        for (int j = 1; j < N; ++j) {
            pw[i][j] = (1LL * pw[i][j - 1] * i) % MOD;
        }
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            sum[i][j] = (j > 0 ? sum[i][j - 1] : 0) + pw[j][i];
            if (sum[i][j] >= MOD) {
                sum[i][j] -= MOD;
            }
        }
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            for (int z = 0; z <= j; ++z) {
                dp[i][j] = (dp[i][j] + 1LL * get_sum(z, a[i], b[i]) * dp[i - 1][j - z]) % MOD;
            }
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}

Submission Info

Submission Time
Task E - Children and Candies
User sankear
Language C++14 (GCC 5.4.1)
Score 800
Code Size 2159 Byte
Status AC
Exec Time 278 ms
Memory 2432 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:64:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", a + i);
                           ^
./Main.cpp:67:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", b + i);
                           ^

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 400 / 400 400 / 400
Status
AC × 5
AC × 12
AC × 30
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt
Subtask 0_001, 0_003, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 2_017.txt, 2_018.txt, 2_019.txt, 2_020.txt, 2_021.txt, 2_022.txt, 2_023.txt, 2_024.txt, 2_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt
Case Name Status Exec Time Memory
0_000.txt AC 10 ms 1792 KB
0_001.txt AC 10 ms 1792 KB
0_002.txt AC 10 ms 1792 KB
0_003.txt AC 9 ms 1792 KB
0_004.txt AC 10 ms 1792 KB
1_005.txt AC 10 ms 1792 KB
1_006.txt AC 10 ms 1792 KB
1_007.txt AC 10 ms 1792 KB
1_008.txt AC 11 ms 1792 KB
1_009.txt AC 11 ms 1792 KB
1_010.txt AC 11 ms 1792 KB
1_011.txt AC 12 ms 2432 KB
1_012.txt AC 12 ms 2432 KB
1_013.txt AC 12 ms 2432 KB
1_014.txt AC 269 ms 2432 KB
1_015.txt AC 271 ms 2432 KB
1_016.txt AC 270 ms 2432 KB
2_017.txt AC 10 ms 1792 KB
2_018.txt AC 10 ms 1792 KB
2_019.txt AC 11 ms 1792 KB
2_020.txt AC 11 ms 1792 KB
2_021.txt AC 12 ms 2432 KB
2_022.txt AC 12 ms 2432 KB
2_023.txt AC 273 ms 2432 KB
2_024.txt AC 278 ms 2432 KB
2_025.txt AC 52 ms 2432 KB
2_026.txt AC 12 ms 2304 KB
2_027.txt AC 221 ms 2432 KB
2_028.txt AC 14 ms 1920 KB
2_029.txt AC 11 ms 1792 KB