Submission #994728

#TimeUsernameProblemLanguageResultExecution timeMemory
994728MisalignedDivTrains (BOI24_trains)C++14
8 / 100
2089 ms2268 KiB
#include <iostream> #include <bits/stdc++.h> #include <map> #include <vector> #include <cmath> #include <algorithm> #include <unistd.h> #include <cstdio> using namespace std; typedef long long ll; typedef unsigned int uint; typedef pair<ll, int> pil; typedef vector<int> vi; typedef long long ll; typedef pair<ll,ll> pll; const int SS = 1e5 + 8, MOD = 1e9 + 7; class Solution{ public: ll N, di, xi, DP[SS]; vector<pll> arr = {{-1, -1}}; ll helper(ll curr){ auto [diff, x] = arr[curr]; DP[curr] = 1; if (diff == 0) return 1; for (int child = diff + curr, t = 0; child <= N && t < x; child += diff, t++){ DP[curr] += helper(child); } return (DP[curr] %= MOD); } ll profitProfit(){ cin >> N; fill(DP, DP + SS, -1); for (int i = 0; i < N; i++){ cin >> di >> xi; arr.push_back( make_pair(di, xi) ); } return helper(1); } }; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); Solution p; cout << p.profitProfit(); }

Compilation message (stderr)

Main.cpp: In member function 'll Solution::helper(ll)':
Main.cpp:26:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   26 |   auto [diff, x] = arr[curr];
      |        ^
#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...