이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
//g++ .cpp -o .exe -g -D_GLIBCXX_DEBUG -ftrapv
//gdb .exe
//b _exit
//r
//(input)
//where
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pear=pair<ll, ll>;
#define fi first
#define se second
#define nl << '\n'
#define uk << ' '
ll mod=1e9+7;
void dfs(ll u, ll& ans, vector<vector<ll>>& adj){
ans++;
ans%=mod;
for(auto v:adj[u]){
dfs(v, ans, adj);
}
return;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
// freopen(".inp","r",stdin);
// freopen(".out","w",stdout);
cin.exceptions(cin.failbit);
ll n;
cin >> n;
ll i, j;
vector<vector<ll>> adj(n+1);
for(i=1; i<=n; i++){
ll d, x;
cin >> d >> x;
if(d==0) continue;
for(j=1; j<=x; j++){
if(i+d*j>n) break;
adj[i].push_back(i+d*j);
}
}
ll ans=0;
dfs(1, ans, adj);
cout << ans;
}
# | 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... |