Submission #1111425

#TimeUsernameProblemLanguageResultExecution timeMemory
1111425gelastropodTrains (BOI24_trains)C++14
8 / 100
939 ms1980 KiB
#include<bits/stdc++.h> using namespace std; #define int long long vector<pair<int, int>> vals; vector<int> dp; int ways(int n) { if (dp[n] != -1) return dp[n]; if (vals[n].first == 0 || n + vals[n].first >= dp.size()) return dp[n] = 1; int ans = 1; for (int i = n + vals[n].first, t = 0; i < dp.size() && t < vals[n].second; i += vals[n].first, t++) { ans += ways(i); } return dp[n] = ans; } signed main() { int N, a, b; cin >> N; dp = vector<int>(N, -1); for (int i = 0; i < N; i++) { cin >> a >> b; vals.push_back({a, b}); } cout << ways(0) << '\n'; }

Compilation message (stderr)

Main.cpp: In function 'long long int ways(long long int)':
Main.cpp:11:49: 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]
   11 |     if (vals[n].first == 0 || n + vals[n].first >= dp.size()) return dp[n] = 1;
      |                               ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
Main.cpp:13:46: 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]
   13 |     for (int i = n + vals[n].first, t = 0; i < dp.size() && t < vals[n].second; i += vals[n].first, t++)
      |                                            ~~^~~~~~~~~~~
#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...