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;
vector<int> stops[10000+10];
int routes(int station){
int ways=1;
for(auto e:stops[station]){
ways+=routes(e);
ways%=(int)1e9+7;
}
return ways;
}
int main()
{
int n,d,x,s;
cin>>n;
for(int i=0;i<n;++i){
cin>>d>>x;
if(d==0){
continue;
}
s=i+1;
for(int j=0;j<x;++j){
if(s+d<=n){
s+=d;
stops[i+1].push_back(s);
}else{
break;
}
}
}
cout<<routes(1)%((int)1e9+7)<<'\n';
return 0;
}
# | 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... |