제출 #995503

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
9955032024-06-09 07:38:4912345678Trains (BOI24_trains)C++17
100 / 100
122 ms5712 KiB
#include <bits/stdc++.h>
using namespace std;
const int nx=1e5+5, mod=1e9+7, kx=255;
int n, d[nx], x[nx], qs[kx][kx], dp[nx], res, k=250;
vector<int> rem[nx];
void add(int idx)
{
if (d[idx]==0||x[idx]==0) return;
if (d[idx]>k)
{
for (int i=idx+d[idx], j=0; j<x[idx]&&i<=n; j++, i+=d[idx]) dp[i]=(dp[i]+dp[idx])%mod;
}
else
{
qs[d[idx]][idx%d[idx]]=(qs[d[idx]][idx%d[idx]]+dp[idx])%mod;
if (idx+((long long)x[idx])*d[idx]<=n) rem[idx+((long long)x[idx])*d[idx]].push_back(idx);
}
}
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=1; i<=n; i++) cin>>d[i]>>x[i];
dp[1]=1;
add(1);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...