Submission #577029

#TimeUsernameProblemLanguageResultExecution timeMemory
577029definitelynotmeeRoller Coaster Railroad (IOI16_railroad)C++98
Compilation error
0 ms0 KiB
    #include<bits/stdc++.h>
    #include"railroad.h"
    #define mp make_pair
    #define mt make_tuple
    #define all(x) x.begin(), x.end()
    #define ff first
    #define ss second
    using namespace std;
    template <typename T>
    using matrix = vector<vector<T>>;
    typedef unsigned int uint;
    typedef unsigned long long ull;
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef pair<ll,ll> pll;
    const ll INFL = (1LL<<62)-1;
    const int INF = (1<<30)-1;
    const double EPS = 1e-7;
    const int MOD = 1e9 + 7;
    const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
    const int MAXN = 1e6+1;
     
    long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
        int n = s.size();
        set<int> vals;
        vals.insert(0);
        vals.insert(INF);
     
        for(int i = 0; i < n; i++){
            vals.insert(s[i]);
            vals.insert(t[i]);
        }
        map<int,int> dic;
     
        for(int i : vals)
            dic[i] = dic.size();
        int m = dic.rbegin()->ss;
     
        for(int i = 0; i < n; i++){
            int u = dic[s[i]], v = dic[t[i]];
            delta[u]--;
            delta[v]++;
            g[u].push_back(v);
        }

        int cur = 1;
        ll resp = 0;
        for(int i = 0; i < m; i++){
            cur+=delta[i];
            if(cur < 0){
                auto it = m.find(i);
                auto it2 = it;
                it2++;
                resp+=abs(cur)*(it2->ss-it->ss);
            }
        }

        return resp;
    }

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:41:13: error: 'delta' was not declared in this scope
   41 |             delta[u]--;
      |             ^~~~~
railroad.cpp:43:13: error: 'g' was not declared in this scope
   43 |             g[u].push_back(v);
      |             ^
railroad.cpp:49:18: error: 'delta' was not declared in this scope
   49 |             cur+=delta[i];
      |                  ^~~~~
railroad.cpp:51:29: error: request for member 'find' in 'm', which is of non-class type 'int'
   51 |                 auto it = m.find(i);
      |                             ^~~~