# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1084755 |
2024-09-06T23:11:22 Z |
zxcigan |
Trains (BOI24_trains) |
C++17 |
|
466 ms |
18200 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 = 1e3;
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 |
4 ms |
8280 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
3 ms |
8144 KB |
Output is correct |
4 |
Correct |
4 ms |
8284 KB |
Output is correct |
5 |
Correct |
3 ms |
8448 KB |
Output is correct |
6 |
Incorrect |
3 ms |
8312 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8280 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
3 ms |
8144 KB |
Output is correct |
4 |
Correct |
4 ms |
8284 KB |
Output is correct |
5 |
Correct |
3 ms |
8448 KB |
Output is correct |
6 |
Incorrect |
3 ms |
8312 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8284 KB |
Output is correct |
2 |
Correct |
34 ms |
8788 KB |
Output is correct |
3 |
Correct |
26 ms |
8540 KB |
Output is correct |
4 |
Correct |
44 ms |
8928 KB |
Output is correct |
5 |
Incorrect |
341 ms |
9044 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
238 ms |
12880 KB |
Output is correct |
2 |
Correct |
197 ms |
12260 KB |
Output is correct |
3 |
Correct |
466 ms |
18200 KB |
Output is correct |
4 |
Correct |
346 ms |
15372 KB |
Output is correct |
5 |
Correct |
3 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
49 ms |
9296 KB |
Output is correct |
8 |
Correct |
461 ms |
18152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8280 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
3 ms |
8144 KB |
Output is correct |
4 |
Correct |
4 ms |
8284 KB |
Output is correct |
5 |
Correct |
3 ms |
8448 KB |
Output is correct |
6 |
Incorrect |
3 ms |
8312 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |