# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1065200 | 2024-08-19T03:08:11 Z | ttttttttttttth | Trains (BOI24_trains) | C++17 | 3 ms | 348 KB |
#include <bits/stdc++.h> using namespace std; #define int long long const long long N = 1e5 + 5; const long long inf = 1e9; const long long mod = 1e9 + 7; const int Block = 300; int n, d[N], x[N]; int dp[N], f[N][Block + 5]; signed main() { ios_base :: sync_with_stdio (0); cin.tie (0); freopen ("BUS.inp", "r", stdin); freopen ("BUS.out", "w", stdout); cin >> n; for (int i = 1; i <= n; i++) { cin >> d[i] >> x[i]; } for (int i = n; i >= 1; i--) { dp[i] = 0; if (d[i] == 0) { dp[i] = 1; } else if (d[i] > Block) { for (int j = i + d[i]; j <= min(n, i + d[i] * x[i]); j += d[i]) { dp[i] = (dp[i] + dp[j]) % mod; } dp[i] = (dp[i] + 1) % mod; } else { dp[i] = 1; dp[i] = (dp[i] + ((i + d[i] <= n) ? (f[i + d[i]][d[i]]) : 0)) % mod; dp[i] = (dp[i] - ((i + d[i] * (x[i] + 1) <= n) ? (f[(i + d[i] * (x[i] + 1))][d[i]]) : 0) + mod * mod) % mod; } for (int j = 0; j <= Block; j++) { f[i][j] = ((i + j <= n ? f[i + j][j] : 0) + dp[i]) % mod; } } cout << dp[1]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |