# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
995349 | 2024-06-08T21:44:34 Z | Lobo | Trains (BOI24_trains) | C++17 | 2 ms | 6748 KB |
#include<bits/stdc++.h> using namespace std; const long long inf = 1e18 + 10; const int inf1 = 1e9 + 10; #define int long long #define dbl long double #define endl '\n' #define sc second #define fr first #define mp make_pair #define pb push_back #define all(x) x.begin(), x.end() mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); const int maxn = 1e5+10; const int B = 500; const int mod = 1e9+7; int n, d[maxn], x[maxn], dp[maxn], tran1[maxn][B+1]; vector<int> tran2[maxn]; void solve() { cin >> n; for(int i = 1; i <= n; i++) { cin >> d[i] >> x[i]; if(d[i] == 0 or x[i] == 0) continue; if(d[i] > B) { for(int j = 1; j <= x[i] && i+j*d[i] <= n; j++) { tran2[i+(j-1)*d[i]].pb(i+j*d[i]); } } else if(i+d[i] <= n) { tran1[i][d[i]] = x[i]; } } dp[1] = 1; vector<int> fq(n+1,0); int ans = 0; for(int i = 1; i <= n; i++) { for(auto j : tran2[i]) { if(fq[j]) continue; fq[j] = 1; dp[j] = (dp[j]+dp[i])%mod; } for(auto j : tran2[i]) { fq[j] = 0; } for(int dif = 1; dif <= B; dif++) { if(tran1[i][dif] != 0) { dp[i+dif] = (dp[i+dif]+dp[i])%mod; tran1[i+dif][dif] = max(tran1[i+dif][dif],tran1[i][dif]-1); } } ans = (ans+dp[i])%mod; } cout << ans << endl; } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); #ifndef ONLINE_JUDGE freopen("in.in", "r", stdin); freopen("out.out", "w", stdout); #endif int tt = 1; // cin >> tt; while(tt--) { solve(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 6744 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 6744 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 6744 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 6748 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 6744 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |