Submission #1033729

#TimeUsernameProblemLanguageResultExecution timeMemory
1033729BuiDucManh123Trains (BOI24_trains)C++14
100 / 100
307 ms165488 KiB
#include <bits/stdc++.h> #define fi first #define se second #define ll long long #define ull unsigned long long #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define taskname "" using namespace std; const int mod=1e9+7; const int block=316; ll n,i,a[100009],d[100009],x[100009],f[350][350],ans[100009],res,j,add[350][100009]; int main() { if (fopen(taskname".inp","r")) { freopen(taskname".inp","r",stdin); freopen(taskname".out","w",stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(i=1;i<=n;i++){ cin>>d[i]>>x[i]; }ans[1]=1; for(i=1;i<=n;i++){ for(j=1;j<block;j++){ f[j][i%j]+=add[j][i]; f[j][i%j]%=mod; f[j][i%j]=(f[j][i%j]+mod)%mod; ans[i]+=f[j][i%j]; ans[i]%=mod; } if(d[i]>=block){ if(d[i]>0){ for(j=i+d[i];j<=min(n,i+d[i]*x[i]);j+=d[i]){ ans[j]+=ans[i]; ans[j]%=mod; } } }else{ if(d[i]>0){ f[d[i]][i%d[i]]+=ans[i]; f[d[i]][i%d[i]]%=mod; if(i+d[i]*(x[i]+1)<=n){ add[d[i]][i+d[i]*(x[i]+1)]-=ans[i]; add[d[i]][i+d[i]*(x[i]+1)]%=mod; } } } }for(i=1;i<=n;i++) res+=ans[i],res%=mod;; cout<<(res+mod)%mod; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:16:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   freopen(taskname".inp","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:17:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   freopen(taskname".out","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...