# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1084757 |
2024-09-06T23:14:10 Z |
zxcigan |
Trains (BOI24_trains) |
C++17 |
|
2000 ms |
1496 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;
const int B = 1;
int dp[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;
dp[1] = 1;
int s = 0;
vector<vector<int>> add (B + 1, vector<int> (B + 1, 0));
set<array<int,4>> st;
for (int i = 1; i <= n; ++i) {
int x, d;
cin >> d >> x;
for (int j = 1; j <= B; ++j) {
(dp[i] += add[j][i % j]) %= mod;
}
if (x && d) {
if (d >= B) {
for (int j = 1; j <= x; ++j) {
if (i + d * j > n) break;
(dp[i + d * j] += dp[i]) %= mod;
}
} else {
(add[d][i % d] += dp[i]) %= mod;
st.insert ({i + x * d, d, i % d, dp[i]});
}
}
while ((int)st.size() && (*st.begin())[0] == i) {
array<int,4> v = (*st.begin());
add[v[1]][v[2]] -= v[3];
while (add[v[1]][v[2]] < 0) add[v[1]][v[2]] += mod;
st.erase (st.begin());
}
(s += dp[i]) %= mod;
}
cout << s << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
5 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
3 ms |
736 KB |
Output is correct |
23 |
Correct |
25 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
3 ms |
600 KB |
Output is correct |
26 |
Correct |
14 ms |
544 KB |
Output is correct |
27 |
Correct |
49 ms |
604 KB |
Output is correct |
28 |
Correct |
9 ms |
600 KB |
Output is correct |
29 |
Correct |
67 ms |
648 KB |
Output is correct |
30 |
Correct |
2 ms |
604 KB |
Output is correct |
31 |
Correct |
41 ms |
604 KB |
Output is correct |
32 |
Correct |
68 ms |
604 KB |
Output is correct |
33 |
Correct |
2 ms |
600 KB |
Output is correct |
34 |
Correct |
1 ms |
604 KB |
Output is correct |
35 |
Correct |
2 ms |
604 KB |
Output is correct |
36 |
Correct |
5 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
26 ms |
348 KB |
Output is correct |
3 |
Correct |
14 ms |
600 KB |
Output is correct |
4 |
Correct |
48 ms |
348 KB |
Output is correct |
5 |
Correct |
6 ms |
860 KB |
Output is correct |
6 |
Execution timed out |
2097 ms |
1496 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
456 ms |
600 KB |
Output is correct |
2 |
Correct |
338 ms |
604 KB |
Output is correct |
3 |
Execution timed out |
2080 ms |
1116 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
5 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
3 ms |
736 KB |
Output is correct |
23 |
Correct |
25 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
3 ms |
600 KB |
Output is correct |
26 |
Correct |
14 ms |
544 KB |
Output is correct |
27 |
Correct |
49 ms |
604 KB |
Output is correct |
28 |
Correct |
9 ms |
600 KB |
Output is correct |
29 |
Correct |
67 ms |
648 KB |
Output is correct |
30 |
Correct |
2 ms |
604 KB |
Output is correct |
31 |
Correct |
41 ms |
604 KB |
Output is correct |
32 |
Correct |
68 ms |
604 KB |
Output is correct |
33 |
Correct |
2 ms |
600 KB |
Output is correct |
34 |
Correct |
1 ms |
604 KB |
Output is correct |
35 |
Correct |
2 ms |
604 KB |
Output is correct |
36 |
Correct |
5 ms |
604 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
26 ms |
348 KB |
Output is correct |
39 |
Correct |
14 ms |
600 KB |
Output is correct |
40 |
Correct |
48 ms |
348 KB |
Output is correct |
41 |
Correct |
6 ms |
860 KB |
Output is correct |
42 |
Execution timed out |
2097 ms |
1496 KB |
Time limit exceeded |
43 |
Halted |
0 ms |
0 KB |
- |