Submission #1000572

#TimeUsernameProblemLanguageResultExecution timeMemory
1000572arashMLGTrains (BOI24_trains)C++17
100 / 100
156 ms7764 KiB
#include<bits/stdc++.h> #ifdef LOCAL #include "Essentials/algo/debug.h" #else #define debug(...) 69 #define debugArr(...) 69 #endif using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const int N = 1e5 + 23; const int sq = 320; const ll mod = 1e9 + 7; const ll inf = 1e18; #define F first #define S second #define pb push_back #define kill(x) cout<<x<<endl, exit(0); #define all(x) x.begin(),x.end() #define sz(x) (int)x.size() #define lc (v << 1) #define rc ((v<<1) |1) #define int ll void ok(int &x) { if(x < 0) x += mod*mod; x %= mod; } int n; int d[N],x[N]; int dp[N]; vector<int> vals[N]; int sum[sq][sq]; int32_t main() { cin.tie(nullptr)->sync_with_stdio(false); cin>>n; for(int i = 1; i <= n ; i ++) cin>>d[i]>>x[i]; dp[1] = 1; int ans = 0; for(int i = 1; i <= n; i ++) { for(int j = 1 ; j < sq; j ++) { ok(dp[i] += sum[j][i%j]); } if(d[i] != 0) { if(d[i] < sq) { ok(sum[d[i]][i%d[i]] += dp[i]); if(i + d[i]*x[i] <= n) { vals[i + d[i]*x[i]].pb(i); } } else { for(int j = i+d[i]; j <= n && x[i]--;j += d[i]) { ok(dp[j] += dp[i]); } } } for(int j : vals[i]) ok(sum[d[j]][j%d[j]] -= dp[j]); ok(ans += dp[i]); debug(i,dp[i]); } cout<<ans << '\n'; return 0; } // Jumpsuit, Jumpsuit cover me! // Jumpsuit, Jumpsuit cover me!

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:5:23: warning: statement has no effect [-Wunused-value]
    5 | #define debug(...)    69
      |                       ^~
Main.cpp:64:3: note: in expansion of macro 'debug'
   64 |   debug(i,dp[i]);
      |   ^~~~~
#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...