답안 #1052948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1052948 2024-08-11T06:36:07 Z Jawad_Akbar_JJ Trains (BOI24_trains) C++17
100 / 100
248 ms 7884 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+=d)
				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 <= 500 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';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 0 ms 4712 KB Output is correct
3 Correct 1 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 0 ms 4700 KB Output is correct
7 Correct 0 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 1 ms 4696 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 1 ms 4700 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 0 ms 4712 KB Output is correct
3 Correct 1 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 0 ms 4700 KB Output is correct
7 Correct 0 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 1 ms 4696 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 1 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 18 ms 4700 KB Output is correct
21 Correct 7 ms 4700 KB Output is correct
22 Correct 24 ms 4876 KB Output is correct
23 Correct 14 ms 4696 KB Output is correct
24 Correct 10 ms 4700 KB Output is correct
25 Correct 19 ms 4764 KB Output is correct
26 Correct 11 ms 4700 KB Output is correct
27 Correct 19 ms 4764 KB Output is correct
28 Correct 27 ms 4772 KB Output is correct
29 Correct 24 ms 4952 KB Output is correct
30 Correct 23 ms 4700 KB Output is correct
31 Correct 27 ms 4700 KB Output is correct
32 Correct 27 ms 4700 KB Output is correct
33 Correct 22 ms 4956 KB Output is correct
34 Correct 22 ms 4824 KB Output is correct
35 Correct 23 ms 4820 KB Output is correct
36 Correct 22 ms 4696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Correct 15 ms 4796 KB Output is correct
3 Correct 10 ms 4696 KB Output is correct
4 Correct 19 ms 4700 KB Output is correct
5 Correct 165 ms 7248 KB Output is correct
6 Correct 212 ms 5292 KB Output is correct
7 Correct 213 ms 5716 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 23 ms 4760 KB Output is correct
12 Correct 223 ms 5284 KB Output is correct
13 Correct 1 ms 4696 KB Output is correct
14 Correct 23 ms 4700 KB Output is correct
15 Correct 220 ms 5460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 4944 KB Output is correct
2 Correct 89 ms 4856 KB Output is correct
3 Correct 220 ms 5312 KB Output is correct
4 Correct 159 ms 5084 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 24 ms 5208 KB Output is correct
8 Correct 228 ms 5340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 0 ms 4712 KB Output is correct
3 Correct 1 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 0 ms 4700 KB Output is correct
7 Correct 0 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 1 ms 4696 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 1 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 18 ms 4700 KB Output is correct
21 Correct 7 ms 4700 KB Output is correct
22 Correct 24 ms 4876 KB Output is correct
23 Correct 14 ms 4696 KB Output is correct
24 Correct 10 ms 4700 KB Output is correct
25 Correct 19 ms 4764 KB Output is correct
26 Correct 11 ms 4700 KB Output is correct
27 Correct 19 ms 4764 KB Output is correct
28 Correct 27 ms 4772 KB Output is correct
29 Correct 24 ms 4952 KB Output is correct
30 Correct 23 ms 4700 KB Output is correct
31 Correct 27 ms 4700 KB Output is correct
32 Correct 27 ms 4700 KB Output is correct
33 Correct 22 ms 4956 KB Output is correct
34 Correct 22 ms 4824 KB Output is correct
35 Correct 23 ms 4820 KB Output is correct
36 Correct 22 ms 4696 KB Output is correct
37 Correct 1 ms 4700 KB Output is correct
38 Correct 15 ms 4796 KB Output is correct
39 Correct 10 ms 4696 KB Output is correct
40 Correct 19 ms 4700 KB Output is correct
41 Correct 165 ms 7248 KB Output is correct
42 Correct 212 ms 5292 KB Output is correct
43 Correct 213 ms 5716 KB Output is correct
44 Correct 1 ms 4700 KB Output is correct
45 Correct 1 ms 4700 KB Output is correct
46 Correct 1 ms 4700 KB Output is correct
47 Correct 23 ms 4760 KB Output is correct
48 Correct 223 ms 5284 KB Output is correct
49 Correct 1 ms 4696 KB Output is correct
50 Correct 23 ms 4700 KB Output is correct
51 Correct 220 ms 5460 KB Output is correct
52 Correct 108 ms 4944 KB Output is correct
53 Correct 89 ms 4856 KB Output is correct
54 Correct 220 ms 5312 KB Output is correct
55 Correct 159 ms 5084 KB Output is correct
56 Correct 1 ms 4696 KB Output is correct
57 Correct 1 ms 4700 KB Output is correct
58 Correct 24 ms 5208 KB Output is correct
59 Correct 228 ms 5340 KB Output is correct
60 Correct 184 ms 5176 KB Output is correct
61 Correct 214 ms 5316 KB Output is correct
62 Correct 218 ms 7884 KB Output is correct
63 Correct 215 ms 5400 KB Output is correct
64 Correct 235 ms 5356 KB Output is correct
65 Correct 248 ms 5528 KB Output is correct
66 Correct 217 ms 5408 KB Output is correct
67 Correct 231 ms 5716 KB Output is correct
68 Correct 220 ms 5308 KB Output is correct
69 Correct 217 ms 7368 KB Output is correct
70 Correct 222 ms 5464 KB Output is correct
71 Correct 220 ms 5492 KB Output is correct
72 Correct 214 ms 5460 KB Output is correct