제출 #1097600

#제출 시각아이디문제언어결과실행 시간메모리
1097600Yadav1992Trains (BOI24_trains)C++14
컴파일 에러
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, ll n, unordered_map<ll, unordered_map<ll, ll> > &pending, unordered_map<ll, vector<vector<ll> > > &ending) { ll i = index % d; vector<ll> end(3); end[0] = d; end[1] = i; end[2] = count; ll endIndex = index + d * x; if(endIndex > n){ endIndex = n; } 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> >(); } ending[endIndex].push_back(end); } void addNext(ll d, ll x, ll index, vector<ll> & dp) { ll value = dp[index]; ll n = (ll)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; if(pending[d][i] == 0) { pending[d].erase(i); } } ending.erase(index); } } 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) && X[i] > 0){ addNext(D[i], X[i], i, dp[i], n, pending, ending); } elif (X[i] > 0) { 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; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:17:16: error: 'unordered_map' was not declared in this scope
   17 | ll processPrev(unordered_map<ll, unordered_map<ll, ll> > &pending, ll index) {
      |                ^~~~~~~~~~~~~
Main.cpp:4:1: note: 'std::unordered_map' is defined in header '<unordered_map>'; did you forget to '#include <unordered_map>'?
    3 | #include <iostream>
  +++ |+#include <unordered_map>
    4 | using namespace std;
Main.cpp:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
Main.cpp:17:30: note: in expansion of macro 'll'
   17 | ll processPrev(unordered_map<ll, unordered_map<ll, ll> > &pending, ll index) {
      |                              ^~
Main.cpp:17:34: error: 'unordered_map' was not declared in this scope
   17 | ll processPrev(unordered_map<ll, unordered_map<ll, ll> > &pending, ll index) {
      |                                  ^~~~~~~~~~~~~
Main.cpp:17:34: note: 'std::unordered_map' is defined in header '<unordered_map>'; did you forget to '#include <unordered_map>'?
Main.cpp:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
Main.cpp:17:48: note: in expansion of macro 'll'
   17 | ll processPrev(unordered_map<ll, unordered_map<ll, ll> > &pending, ll index) {
      |                                                ^~
Main.cpp:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
Main.cpp:17:52: note: in expansion of macro 'll'
   17 | ll processPrev(unordered_map<ll, unordered_map<ll, ll> > &pending, ll index) {
      |                                                    ^~
Main.cpp:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
Main.cpp:17:68: note: in expansion of macro 'll'
   17 | ll processPrev(unordered_map<ll, unordered_map<ll, ll> > &pending, ll index) {
      |                                                                    ^~
Main.cpp:17:76: error: expression list treated as compound expression in initializer [-fpermissive]
   17 | ll processPrev(unordered_map<ll, unordered_map<ll, ll> > &pending, ll index) {
      |                                                                            ^
Main.cpp:30:52: error: 'unordered_map' has not been declared
   30 | void addNext(ll d, ll x, ll index, ll count, ll n, unordered_map<ll, unordered_map<ll, ll> > &pending,
      |                                                    ^~~~~~~~~~~~~
Main.cpp:30:65: error: expected ',' or '...' before '<' token
   30 | void addNext(ll d, ll x, ll index, ll count, ll n, unordered_map<ll, unordered_map<ll, ll> > &pending,
      |                                                                 ^
Main.cpp: In function 'void addNext(long long int, long long int, long long int, long long int, long long int, int)':
Main.cpp:42:8: error: 'pending' was not declared in this scope
   42 |     if(pending.find(d) == pending.end()){
      |        ^~~~~~~
Main.cpp:43:22: error: 'unordered_map' was not declared in this scope
   43 |         pending[d] = unordered_map<ll, ll>();
      |                      ^~~~~~~~~~~~~
Main.cpp:43:22: note: 'std::unordered_map' is defined in header '<unordered_map>'; did you forget to '#include <unordered_map>'?
Main.cpp:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
Main.cpp:43:36: note: in expansion of macro 'll'
   43 |         pending[d] = unordered_map<ll, ll>();
      |                                    ^~
Main.cpp:45:5: error: 'pending' was not declared in this scope
   45 |     pending[d][i] += count;
      |     ^~~~~~~
Main.cpp:47:8: error: 'ending' was not declared in this scope
   47 |     if(ending.find(endIndex) == ending.end()){
      |        ^~~~~~
Main.cpp:50:5: error: 'ending' was not declared in this scope
   50 |     ending[endIndex].push_back(end);
      |     ^~~~~~
Main.cpp: At global scope:
Main.cpp:64:6: error: variable or field 'deletePrev' declared void
   64 | void deletePrev(unordered_map<ll, unordered_map<ll, ll> > & pending,
      |      ^~~~~~~~~~
Main.cpp:64:17: error: 'unordered_map' was not declared in this scope
   64 | void deletePrev(unordered_map<ll, unordered_map<ll, ll> > & pending,
      |                 ^~~~~~~~~~~~~
Main.cpp:64:17: note: 'std::unordered_map' is defined in header '<unordered_map>'; did you forget to '#include <unordered_map>'?
Main.cpp:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
Main.cpp:64:31: note: in expansion of macro 'll'
   64 | void deletePrev(unordered_map<ll, unordered_map<ll, ll> > & pending,
      |                               ^~
Main.cpp:64:35: error: 'unordered_map' was not declared in this scope
   64 | void deletePrev(unordered_map<ll, unordered_map<ll, ll> > & pending,
      |                                   ^~~~~~~~~~~~~
Main.cpp:64:35: note: 'std::unordered_map' is defined in header '<unordered_map>'; did you forget to '#include <unordered_map>'?
Main.cpp:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
Main.cpp:64:49: note: in expansion of macro 'll'
   64 | void deletePrev(unordered_map<ll, unordered_map<ll, ll> > & pending,
      |                                                 ^~
Main.cpp:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
Main.cpp:64:53: note: in expansion of macro 'll'
   64 | void deletePrev(unordered_map<ll, unordered_map<ll, ll> > & pending,
      |                                                     ^~
Main.cpp:65:5: error: 'unordered_map' was not declared in this scope
   65 |     unordered_map<ll, vector<vector<ll> > > & ending, ll index)
      |     ^~~~~~~~~~~~~
Main.cpp:65:5: note: 'std::unordered_map' is defined in header '<unordered_map>'; did you forget to '#include <unordered_map>'?
Main.cpp:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
Main.cpp:65:19: note: in expansion of macro 'll'
   65 |     unordered_map<ll, vector<vector<ll> > > & ending, ll index)
      |                   ^~
Main.cpp:65:43: error: expected primary-expression before '>' token
   65 |     unordered_map<ll, vector<vector<ll> > > & ending, ll index)
      |                                           ^
Main.cpp:65:47: error: 'ending' was not declared in this scope
   65 |     unordered_map<ll, vector<vector<ll> > > & ending, ll index)
      |                                               ^~~~~~
Main.cpp:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
Main.cpp:65:55: note: in expansion of macro 'll'
   65 |     unordered_map<ll, vector<vector<ll> > > & ending, ll index)
      |                                                       ^~
Main.cpp: In function 'void solve(long long int, std::vector<long long int>&, std::vector<long long int>&)':
Main.cpp:83:5: error: 'unordered_map' was not declared in this scope
   83 |     unordered_map<ll, unordered_map<ll, ll> > pending;
      |     ^~~~~~~~~~~~~
Main.cpp:83:5: note: 'std::unordered_map' is defined in header '<unordered_map>'; did you forget to '#include <unordered_map>'?
Main.cpp:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
Main.cpp:83:19: note: in expansion of macro 'll'
   83 |     unordered_map<ll, unordered_map<ll, ll> > pending;
      |                   ^~
Main.cpp:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
Main.cpp:84:19: note: in expansion of macro 'll'
   84 |     unordered_map<ll, vector<vector<ll> > > ending;
      |                   ^~
Main.cpp:88:30: error: 'pending' was not declared in this scope
   88 |         dp[i] += processPrev(pending, i);
      |                              ^~~~~~~
Main.cpp:88:40: error: 'processPrev' cannot be used as a function
   88 |         dp[i] += processPrev(pending, i);
      |                                        ^
Main.cpp:90:23: error: 'sqrt' was not declared in this scope
   90 |         if(D[i] < (ll)sqrt(n) && X[i] > 0){
      |                       ^~~~
Main.cpp:91:55: error: 'ending' was not declared in this scope
   91 |             addNext(D[i], X[i], i, dp[i], n, pending, ending);
      |                                                       ^~~~~~
Main.cpp:92:11: error: 'elif' was not declared in this scope
   92 |         } elif (X[i] > 0) {
      |           ^~~~
Main.cpp:96:29: error: 'ending' was not declared in this scope
   96 |         deletePrev(pending, ending, i);
      |                             ^~~~~~
Main.cpp:96:9: error: 'deletePrev' was not declared in this scope
   96 |         deletePrev(pending, ending, i);
      |         ^~~~~~~~~~