Submission #1064115

#TimeUsernameProblemLanguageResultExecution timeMemory
1064115Theo830Rail (IOI14_rail)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
#include "rail.h"
void findLocation(int n, int first, int location[], int stype[]){
    location[0] = first;
    stype[0] = 1;
    ll dist[n][n];
    f(i,0,n){
        dist[i][i] = 0;
        f(j,i+1,n){
            dist[i][j] = dist[j][i] = getDistance(i,j);
        }
    }
    ll mini = INF;
    ll pos;
    f(i,1,n){
        if(mini > dist[0][i]){
            mini = dist[0][i];
            pos = i;
        }
    }
    stype[pos] = 2;
    location[pos] = first + dist[0][pos];
    ll ex = 2;
    set<iii>dista;
    bool v[n] = {0};
    ex.pb(0);
    ex.pb(pos);
    v[0] = v[pos] = 1;
    f(i,0,n){
        dista.insert(iii(dist[i][0],ii(i,0)));
        dista.insert(iii(dist[i][pos],ii(i,pos)));
    }
    while(ex != n){
        ll pos,prev,mini;
        while(1){
            auto it = dista.begin();
            iii w = (*it);
            dista.erase(w);
            if(!v[w.S.F]){
                mini = w.F;
                prev = w.S.S;
                pos = w.S.F;
                break;
            }
        }
        if(stype[prev] == 1){
            stype[pos] = 2;
            location[pos] = location[prev] + mini;
        }
        else{
            stype[pos] = 1;
            location[pos] = location[prev] - mini;
        }
        v[pos] = 1;
        ex++;
        f(i,0,n)[
            dista.insert(iii(dist[i][pos],ii(i,pos)));
        ]
    }
}

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:9:12: error: request for member 'push_back' in 'ex', which is of non-class type 'll' {aka 'long long int'}
    9 | #define pb push_back
      |            ^~~~~~~~~
rail.cpp:49:8: note: in expansion of macro 'pb'
   49 |     ex.pb(0);
      |        ^~
rail.cpp:9:12: error: request for member 'push_back' in 'ex', which is of non-class type 'll' {aka 'long long int'}
    9 | #define pb push_back
      |            ^~~~~~~~~
rail.cpp:50:8: note: in expansion of macro 'pb'
   50 |     ex.pb(pos);
      |        ^~
rail.cpp:80:18: error: expected ',' before '.' token
   80 |             dista.insert(iii(dist[i][pos],ii(i,pos)));
      |                  ^
      |                  ,
rail.cpp:80:18: error: expected identifier before '.' token
rail.cpp:80:54: error: expected ']' before ';' token
   80 |             dista.insert(iii(dist[i][pos],ii(i,pos)));
      |                                                      ^
      |                                                      ]
rail.cpp: In lambda function:
rail.cpp:80:54: error: expected '{' before ';' token
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:81:9: error: expected primary-expression before ']' token
   81 |         ]
      |         ^