Submission #1084747

# Submission time Handle Problem Language Result Execution time Memory
1084747 2024-09-06T22:38:59 Z zxcigan Trains (BOI24_trains) C++17
21 / 100
1211 ms 1048576 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int long long
const int N = 2e5;
const int mod = 1e9 + 7;
int dp[N];
vector<int> g[N];
int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int x, d;
        cin >> d >> x;
        if (x && d) {
            for (int j = 1; j <= x; ++j) {
                if (i + d * j > n) break;
//                if (i == 1) cout << i << ' ' << d << ' ' << j << ' ' << i + d * j << '\n';
                g[i + d * j].push_back(i);
            }
        }
    }
    dp[1] = 1;
    int s = 0;
    for (int i = 1; i <= n; ++i) {
        for (auto to : g[i]) {
            (dp[i] += dp[to]) %= mod;
        }
        (s += dp[i]) %= mod;
    }
//    cout << g[2].size() << '\n';
    cout << s << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 2 ms 5028 KB Output is correct
7 Correct 2 ms 4952 KB Output is correct
8 Correct 2 ms 4924 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 5160 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 2 ms 5016 KB Output is correct
17 Correct 3 ms 4956 KB Output is correct
18 Correct 3 ms 4956 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 2 ms 5028 KB Output is correct
7 Correct 2 ms 4952 KB Output is correct
8 Correct 2 ms 4924 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 5160 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 2 ms 5016 KB Output is correct
17 Correct 3 ms 4956 KB Output is correct
18 Correct 3 ms 4956 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 47 ms 35152 KB Output is correct
21 Correct 3 ms 5212 KB Output is correct
22 Correct 12 ms 9820 KB Output is correct
23 Correct 286 ms 194640 KB Output is correct
24 Correct 4 ms 5468 KB Output is correct
25 Correct 32 ms 24120 KB Output is correct
26 Correct 154 ms 107628 KB Output is correct
27 Correct 530 ms 358224 KB Output is correct
28 Correct 91 ms 66128 KB Output is correct
29 Correct 743 ms 508240 KB Output is correct
30 Correct 6 ms 6488 KB Output is correct
31 Correct 380 ms 259924 KB Output is correct
32 Correct 757 ms 508348 KB Output is correct
33 Correct 16 ms 10076 KB Output is correct
34 Correct 5 ms 5976 KB Output is correct
35 Correct 4 ms 5468 KB Output is correct
36 Correct 46 ms 35412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5164 KB Output is correct
2 Correct 285 ms 194616 KB Output is correct
3 Correct 154 ms 107668 KB Output is correct
4 Correct 553 ms 358228 KB Output is correct
5 Correct 22 ms 9292 KB Output is correct
6 Runtime error 1052 ms 1048576 KB Execution killed with signal 9
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1211 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 2 ms 5028 KB Output is correct
7 Correct 2 ms 4952 KB Output is correct
8 Correct 2 ms 4924 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 5160 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 2 ms 5016 KB Output is correct
17 Correct 3 ms 4956 KB Output is correct
18 Correct 3 ms 4956 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 47 ms 35152 KB Output is correct
21 Correct 3 ms 5212 KB Output is correct
22 Correct 12 ms 9820 KB Output is correct
23 Correct 286 ms 194640 KB Output is correct
24 Correct 4 ms 5468 KB Output is correct
25 Correct 32 ms 24120 KB Output is correct
26 Correct 154 ms 107628 KB Output is correct
27 Correct 530 ms 358224 KB Output is correct
28 Correct 91 ms 66128 KB Output is correct
29 Correct 743 ms 508240 KB Output is correct
30 Correct 6 ms 6488 KB Output is correct
31 Correct 380 ms 259924 KB Output is correct
32 Correct 757 ms 508348 KB Output is correct
33 Correct 16 ms 10076 KB Output is correct
34 Correct 5 ms 5976 KB Output is correct
35 Correct 4 ms 5468 KB Output is correct
36 Correct 46 ms 35412 KB Output is correct
37 Correct 2 ms 5164 KB Output is correct
38 Correct 285 ms 194616 KB Output is correct
39 Correct 154 ms 107668 KB Output is correct
40 Correct 553 ms 358228 KB Output is correct
41 Correct 22 ms 9292 KB Output is correct
42 Runtime error 1052 ms 1048576 KB Execution killed with signal 9
43 Halted 0 ms 0 KB -