Submission #1111587

#TimeUsernameProblemLanguageResultExecution timeMemory
1111587gohchingjaykTrains (BOI24_trains)C++17
0 / 100
2 ms1616 KiB
#include <bits/stdc++.h> using namespace std; using i64 = int64_t; int mod = 1'000'000'007; vector<int> parents[10000]; int dp[10000]; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int N; cin >> N; for (int i = 0; i < N; ++i) { int d, x; cin >> d >> x; if (d == 0) continue; int realparent = i; for (int parent : parents[i]) { if (parent % d == i % d) { realparent = parent; break; } } for (int j = i + d; j < N && j <= i + d * x; ++j) { parents[j].emplace_back(realparent); } } memset(dp, 0, sizeof(dp)); int sum = dp[0] = 1; for (int i = 1; i < N; ++i) { for (int parent : parents[i]) { dp[i] = (dp[i] + dp[parent]) % mod; } sum = (sum + dp[i]) % mod; } cout << sum; }
#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...