Submission #49383

#TimeUsernameProblemLanguageResultExecution timeMemory
49383imeimi2000Rail (IOI14_rail)C++17
Compilation error
0 ms0 KiB
#include "rail.h"
#include <algorithm>
#include <set>

using namespace std;

const int MAXN = 5000;
int n;
int d0[MAXN];
int d1[MAXN];
int rd[MAXN];
int *l, *t;

void calc(vector<int> &ps, int s) {
    sort(ps.begin(), ps.end(), [&](int i, int j) { return rd[i] < rd[j]; });
    set<int> mp;
    l[ps[0]] = l[s] + rd[ps[0]];
    t[ps[0]] = 2;
    int mx = ps[0];
    mp.insert(l[mx] << 1);
    for (int i = 1; i < ps.size(); ++i) {
        int fn = (l[mx] << 1) + rd[ps[i]] - rd[mx] - getDistance(ps[i], mx);
        if (mp.find(fn) != mp.end()) {
            l[ps[i]] = fn - rd[ps[i]] - l[s];
            t[ps[i]] = 1;
        }
        else {
            l[ps[i]] = l[s] + rd[ps[i]];
            t[ps[i]] = 2;
            mp.insert(l[ps[i]] << 1);
            mx = ps[i];
        }
    }
}

void findLocation(int N, int f, int _l[], int _t[]) {
    n = N;
    l = _l;
    t = _t;
    
    int mn = 1;
    for (int i = 1; i < n; ++i) {
        d0[i] = getDistance(0, i);
        if (d0[i] < d0[mn]) mn = i;
    }
    d1[0] = d0[mn];
    vector<int> vt1, vt2;
    rd[0] = rd[mn] = d1[0];
    vt1.push_back(0);
    vt2.push_back(mn);
    for (int i = 1; i < n; ++i) {
        if (mn == i) continue;
        d1[i] = getDistance(mn, i);
        if (d0[i] == d1[i] + d1[0]) vt1.push_back(i), rd[i] = d1[i];
        else vt2.push_back(i), rd[i] = d0[i];
    }
    l[0] = f;
    t[0] = 1;
    calc(vt2, 0);
    l[mn] = -(f + d1[0]);
    t[mn] = 1;
    calc(vt1, mn);
    l[mn] = -l[mn];
    t[mn] = 2;
    for (int i : vt1) {
        l[i] = -l[i];
        t[i] ^= 3;
    }
}

Compilation message (stderr)

rail.cpp:14:11: error: variable or field 'calc' declared void
 void calc(vector<int> &ps, int s) {
           ^~~~~~
rail.cpp:14:11: error: 'vector' was not declared in this scope
rail.cpp:14:11: note: suggested alternative: 'perror'
 void calc(vector<int> &ps, int s) {
           ^~~~~~
           perror
rail.cpp:14:18: error: expected primary-expression before 'int'
 void calc(vector<int> &ps, int s) {
                  ^~~
rail.cpp:14:28: error: expected primary-expression before 'int'
 void calc(vector<int> &ps, int s) {
                            ^~~
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:47:5: error: 'vector' was not declared in this scope
     vector<int> vt1, vt2;
     ^~~~~~
rail.cpp:47:5: note: suggested alternative: 'perror'
     vector<int> vt1, vt2;
     ^~~~~~
     perror
rail.cpp:47:12: error: expected primary-expression before 'int'
     vector<int> vt1, vt2;
            ^~~
rail.cpp:49:5: error: 'vt1' was not declared in this scope
     vt1.push_back(0);
     ^~~
rail.cpp:50:5: error: 'vt2' was not declared in this scope
     vt2.push_back(mn);
     ^~~
rail.cpp:59:5: error: 'calc' was not declared in this scope
     calc(vt2, 0);
     ^~~~
rail.cpp:59:5: note: suggested alternative: 'calloc'
     calc(vt2, 0);
     ^~~~
     calloc
rail.cpp:65:18: error: unable to deduce 'auto&&' from 'vt1'
     for (int i : vt1) {
                  ^~~