Submission #1097567

#TimeUsernameProblemLanguageResultExecution timeMemory
1097567Yadav1992Trains (BOI24_trains)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <vector> #include <iostream> using namespace std; #define ll long long #define mod 1000000007 ll calculateTotal(vector<ll> &dp){ ll total = 0; for(auto entry : dp){ total += entry; total %= mod; } return total; } ll processPrev(unordered_map<ll, unordered_map<ll, ll> > &pending, ll index) { ll answer = 0; for(auto& entry : pending){ ll d = entry.first; auto& countMap = entry.second; if(countMap.find(index % d) != countMap.end()){ answer += countMap[index % d]; answer %= mod; } } return answer; } void addNext(ll d, ll x, ll index, ll count, unordered_map<ll, unordered_map<ll, ll> > &pending, unordered_map<ll, vector<vector<ll> > > &ending) { ll i = index % d; vector<ll> end = {d, i, count}; ll endIndex = index + d * x; if(pending.find(d) == pending.end()){ pending[d] = unordered_map<ll, ll>(); } pending[d][i] += count; if(ending.find(endIndex)) == ending.end()){ ending[endIndex] = vector<vector<ll> >(); } endind[endIndex].push_back(end); } void addNext(ll d, ll x, ll index, vector<ll> & dp) { ll value = dp[index]; ll n = dp.size(); for(ll i = index + d; i < n && i <= index + d * x; i+= d) { dp[i] += value; dp[i] %= mod; } } void deletePrev(unordered_map<ll, unordered_map<ll, ll> > & pending, unordered_map<ll, vector<vector<ll> > > & ending, ll index) { if(ending.find(index) != ending.end()){ auto & entries = ending[index]; for(auto & entry : entries){ ll d = entry[0], i = entry[1], count = entry[2]; pending[d][i] += mod - count; pending[d][i] %= mod; } } } void solve(ll n, vector<ll> &D, vector<ll> &X) { unordered_map<ll, unordered_map<ll, ll> > pending; unordered_map<ll, vector<vector<ll> > > ending; vector<ll> dp(n, 0); dp[0] = 1; for(int i = 0; i < n; i++) { dp[i] += processPrev(pending, i); dp[i] %= mod; if(D[i] < (ll)sqrt(n)){ addNext(D[i], X[i], i, dp[i], pending, ending); } else { addNext(D[i], X[i], i, dp); } deletePrev(pending, ending, i); } cout << calculateTotal(dp); } int main() { ll n=1; cin>>n; vector<ll> D; vector<ll> X; ll i = n; while(i--) { ll d, x; cin >> d >> x; D.push_back(d); X.push_back(x); } solve(n, D, X); return 0; }

Compilation message (stderr)

Main.cpp: In function 'void addNext(long long int, long long int, long long int, long long int, std::unordered_map<long long int, std::unordered_map<long long int, long long int> >&, std::unordered_map<long long int, std::vector<std::vector<long long int> > >&)':
Main.cpp:42:19: error: could not convert '(& ending)->std::unordered_map<long long int, std::vector<std::vector<long long int> > >::find(endIndex)' from 'std::unordered_map<long long int, std::vector<std::vector<long long int> > >::iterator' {aka 'std::__detail::_Hashtable_base<long long int, std::pair<const long long int, std::vector<std::vector<long long int> > >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} to 'bool'
   42 |     if(ending.find(endIndex)) == ending.end()){
      |        ~~~~~~~~~~~^~~~~~~~~~
      |                   |
      |                   std::unordered_map<long long int, std::vector<std::vector<long long int> > >::iterator {aka std::__detail::_Hashtable_base<long long int, std::pair<const long long int, std::vector<std::vector<long long int> > >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<false, false, true> >::iterator}
Main.cpp:42:31: error: expected primary-expression before '==' token
   42 |     if(ending.find(endIndex)) == ending.end()){
      |                               ^~
Main.cpp:45:5: error: 'endind' was not declared in this scope; did you mean 'ending'?
   45 |     endind[endIndex].push_back(end);
      |     ^~~~~~
      |     ending