This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
int mod = 1'000'000'007;
vector<int> parents[10000];
bool dp[10000];
int search(int i) {
int ans = 0;
if (i == 0) return 1;
if (dp[i]) return 0;
for (int parent : parents[i]) {
ans = (ans + search(parent)) % mod;
}
dp[i] = true;
return ans;
}
int main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(false);
int N; cin >> N;
for (int i = 0; i < N; ++i) {
int d, x;
cin >> d >> x;
if (d == 0) continue;
for (int j = i + d; j < N && j <= i + d * x; ++j) {
parents[j].emplace_back(i);
}
}
int sum = 1;
for (int i = 1; i < N; ++i)
{
memset(dp, 0, sizeof(dp));
sum = (sum + search(i)) % mod;
}
cout << sum;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |