Submission #1052939

# Submission time Handle Problem Language Result Execution time Memory
1052939 2024-08-11T06:23:47 Z vjudge1 Trains (BOI24_trains) C++17
58 / 100
233 ms 9308 KB
#include <iostream>
#include <vector>

using namespace std;
#define int long long
const int N = 1e5 + 5;
int dp[N], mod = 1e9 + 7, Ans;
int Mod[505][505];
vector<pair<int,int>> rem[N];

signed main(){
	int n;
	cin>>n;
	dp[1] = 1;
	for (int i=1, d, x;i<=n;i++){
		cin>>d>>x;
		for (int m=1;m<=500;m++)
			dp[i] = (dp[i] + Mod[m][i % m]) % mod;

		if (d > 500){
			for (int j=d;j/d<=x and i + j <= n;j++)
				dp[j + i] = (dp[j + i] + dp[i]) % mod;
		}
		else if (d){
			Mod[d][i % d] = (Mod[d][i % d] + dp[i]) % mod;
		}

		if (d and d * x + i <= n)
			rem[d * x + i].push_back({i, d});
		
		for (auto [ind, d_ind] : rem[i])
			Mod[d_ind][ind % d_ind] = (Mod[d_ind][ind % d_ind] - dp[ind] + mod) % mod;
		Ans = (Ans + dp[i]) % mod;
		// exit by removing those 
	}
	cout<<Ans<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 0 ms 4700 KB Output is correct
4 Correct 0 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 0 ms 4700 KB Output is correct
9 Correct 0 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 0 ms 4700 KB Output is correct
12 Correct 1 ms 4700 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4700 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Correct 0 ms 4700 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 0 ms 4700 KB Output is correct
4 Correct 0 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 0 ms 4700 KB Output is correct
9 Correct 0 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 0 ms 4700 KB Output is correct
12 Correct 1 ms 4700 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4700 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Correct 0 ms 4700 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
20 Correct 19 ms 4696 KB Output is correct
21 Runtime error 8 ms 9308 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Correct 15 ms 4780 KB Output is correct
3 Correct 11 ms 4764 KB Output is correct
4 Correct 19 ms 4700 KB Output is correct
5 Correct 164 ms 7276 KB Output is correct
6 Correct 233 ms 5396 KB Output is correct
7 Correct 225 ms 5716 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 0 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 22 ms 4772 KB Output is correct
12 Correct 219 ms 5300 KB Output is correct
13 Correct 1 ms 4696 KB Output is correct
14 Correct 23 ms 4968 KB Output is correct
15 Correct 217 ms 5460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 4948 KB Output is correct
2 Correct 89 ms 4816 KB Output is correct
3 Correct 221 ms 5456 KB Output is correct
4 Correct 158 ms 5244 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 23 ms 4772 KB Output is correct
8 Correct 220 ms 5712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 0 ms 4700 KB Output is correct
4 Correct 0 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 0 ms 4700 KB Output is correct
9 Correct 0 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 0 ms 4700 KB Output is correct
12 Correct 1 ms 4700 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4700 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Correct 0 ms 4700 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
20 Correct 19 ms 4696 KB Output is correct
21 Runtime error 8 ms 9308 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -