Submission #1028077

#TimeUsernameProblemLanguageResultExecution timeMemory
1028077AbitoTrains (BOI24_trains)C++17
100 / 100
606 ms259664 KiB
#include <bits/stdc++.h> #define F first #define S second #define pb push_back #define ppb pop_back #define ep insert #define endl '\n' #define elif else if #define pow pwr #define sqrt sqrtt #define int long long #define ll long long #define y1 YONE typedef unsigned long long ull; using namespace std; const int N=1e5+5,M=1e9+7,S=300; int dp[N],d[N],x[N],n; vector<int> s[S+5][S]; int32_t main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin>>n; for (int i=1;i<=n;i++) cin>>d[i]>>x[i]; for (int i=1;i<=S;i++){ int sz=n/i+50; for (int j=0;j<i;j++) s[i][j].resize(sz,0); } for (int i=n;i;i--){ dp[i]=1; if (d[i]>S){ for (int j=i+d[i];j<=n && j<=i+d[i]*x[i];j+=d[i]) dp[i]=(dp[i]+dp[j])%M; } elif (d[i] && x[i]){ int l=i/d[i]+1,r=l+x[i]; if (r>=s[d[i]][i%d[i]].size()){ dp[i]=(s[d[i]][i%d[i]][l]+1)%M; } //cout<<i<<' '<<l<<' '<<r<<endl; else dp[i]=((s[d[i]][i%d[i]][l]-s[d[i]][i%d[i]][r]+M)%M+1)%M; } for (int j=1;j<=S;j++){ s[j][i%j][i/j]=(s[j][i%j][i/j+1]+dp[i])%M; } } //for (int i=1;i<=n;i++) cout<<dp[i]<<' ';cout<<endl; cout<<dp[1]<<endl; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:34:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             if (r>=s[d[i]][i%d[i]].size()){
      |                 ~^~~~~~~~~~~~~~~~~~~~~~~~
#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...