Submission #480621

#TimeUsernameProblemLanguageResultExecution timeMemory
480621CyberSleeperRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "race.h"

#define pii     pair<ll, ll>
#define fi      first
#define se      second
#define pb      push_back

using namespace std;

const ll MX=200007, INF=1e9+7;

vector<pii> adj[MX];
map<ll, pii> ada[MX];
ll N, K, ret=INF;

void add(ll i, ll j, ll x){
    if(ada[i].count(j)){
        pii now=ada[i][j];
        if(now.se>x)
            now.se=x;
        if(now.fi>now.se)
            swap(now.fi, now.se);
        ada[i][j]=now;
    }else{
        ada[i][j]={x, INF};
    }
}
void calc(ll x){
    cout << endl;
    cout << x << endl;
    for(auto ii:ada[x]){
        ll i=ii.fi, j=K-i;
        cout << "i: " << i << endl;
        if(i>=(K+1)/2)
            break;
        if(ada[x].count(i) && ada[x].count(j)){
            cout << i << ' ' << j << " good\n";
            ret=min(ret, ada[x][i].fi+ada[x][j].fi);
            cout << ada[x][i].fi << " ::: " << ada[x][j].fi << endl;
        }
    }
    if(K%2==0){
        ll k=K/2;
        if(ada[x].count(k)){
            pii tmp=ada[x][k];
            if(tmp.se && tmp.se!=INF){
                ret=min(ret, tmp.fi+tmp.se);
                cout << "double: " << tmp.fi << ' ' << tmp.se << endl;
            }
        }
    }
}
void DFS(ll par, ll wpar, ll x){
    ada[x][0]={0, INF};
    for(auto i:adj[x]){
        ll v=i.fi, w=i.se;
        if(v==par)
            continue;
        DFS(x, w, v);
        if(ada[x].size()<ada[v].size())
            swap(ada[x], ada[v]);
        for(auto j:ada[v]){
            ll tot=j.fi, sisa=K-tot;
            pii cnt=j.se;
            if(tot>K)
                continue;
            if(ada[x].count(sisa)){
                ret=min(ret, ada[x][sisa].fi+ada[v][tot].fi);
            }
            add(x, tot, cnt.fi);
            add(x, tot, cnt.se);
        }
    }
    if(!x)
        return;
    vector<ll> delay;
    for(auto i=ada[x].rbegin(); i!=ada[x].rend(); i++){
        pair<ll, pii> tmp=*i;

            tmp.se.fi++;
            tmp.se.se++;
            ada[x][tmp.fi+wpar]=tmp.se;
            delay.pb(tmp.fi);

    }
    for(auto i:delay)
        ada[x].erase(i);
}

ll best_path(ll n, ll k, ll H[][2], ll L[]){
    N=n, K=k;
    for(ll i=0, u, v, w; i<N-1; i++){
        u=H[i][0], v=H[i][1], w=L[i];
        adj[u].pb({v, w});
        adj[v].pb({u, w});
    }
    DFS(0, 0, 0);
    return (ret>=INF?-1:ret);
}

Compilation message (stderr)

race.cpp:11:7: error: 'll' does not name a type
   11 | const ll MX=200007, INF=1e9+7;
      |       ^~
race.cpp:4:22: error: 'll' was not declared in this scope
    4 | #define pii     pair<ll, ll>
      |                      ^~
race.cpp:13:8: note: in expansion of macro 'pii'
   13 | vector<pii> adj[MX];
      |        ^~~
race.cpp:4:26: error: 'll' was not declared in this scope
    4 | #define pii     pair<ll, ll>
      |                          ^~
race.cpp:13:8: note: in expansion of macro 'pii'
   13 | vector<pii> adj[MX];
      |        ^~~
race.cpp:4:28: error: template argument 1 is invalid
    4 | #define pii     pair<ll, ll>
      |                            ^
race.cpp:13:8: note: in expansion of macro 'pii'
   13 | vector<pii> adj[MX];
      |        ^~~
race.cpp:4:28: error: template argument 2 is invalid
    4 | #define pii     pair<ll, ll>
      |                            ^
race.cpp:13:8: note: in expansion of macro 'pii'
   13 | vector<pii> adj[MX];
      |        ^~~
race.cpp:13:11: error: template argument 1 is invalid
   13 | vector<pii> adj[MX];
      |           ^
race.cpp:13:11: error: template argument 2 is invalid
race.cpp:13:17: error: 'MX' was not declared in this scope
   13 | vector<pii> adj[MX];
      |                 ^~
race.cpp:14:5: error: 'll' was not declared in this scope
   14 | map<ll, pii> ada[MX];
      |     ^~
race.cpp:4:22: error: 'll' was not declared in this scope
    4 | #define pii     pair<ll, ll>
      |                      ^~
race.cpp:14:9: note: in expansion of macro 'pii'
   14 | map<ll, pii> ada[MX];
      |         ^~~
race.cpp:4:26: error: 'll' was not declared in this scope
    4 | #define pii     pair<ll, ll>
      |                          ^~
race.cpp:14:9: note: in expansion of macro 'pii'
   14 | map<ll, pii> ada[MX];
      |         ^~~
race.cpp:4:28: error: template argument 1 is invalid
    4 | #define pii     pair<ll, ll>
      |                            ^
race.cpp:14:9: note: in expansion of macro 'pii'
   14 | map<ll, pii> ada[MX];
      |         ^~~
race.cpp:4:28: error: template argument 2 is invalid
    4 | #define pii     pair<ll, ll>
      |                            ^
race.cpp:14:9: note: in expansion of macro 'pii'
   14 | map<ll, pii> ada[MX];
      |         ^~~
race.cpp:14:12: error: template argument 1 is invalid
   14 | map<ll, pii> ada[MX];
      |            ^
race.cpp:14:12: error: template argument 2 is invalid
race.cpp:14:12: error: template argument 3 is invalid
race.cpp:14:12: error: template argument 4 is invalid
race.cpp:14:18: error: 'MX' was not declared in this scope
   14 | map<ll, pii> ada[MX];
      |                  ^~
race.cpp:15:1: error: 'll' does not name a type
   15 | ll N, K, ret=INF;
      | ^~
race.cpp:17:6: error: variable or field 'add' declared void
   17 | void add(ll i, ll j, ll x){
      |      ^~~
race.cpp:17:10: error: 'll' was not declared in this scope
   17 | void add(ll i, ll j, ll x){
      |          ^~
race.cpp:17:16: error: 'll' was not declared in this scope
   17 | void add(ll i, ll j, ll x){
      |                ^~
race.cpp:17:22: error: 'll' was not declared in this scope
   17 | void add(ll i, ll j, ll x){
      |                      ^~
race.cpp:29:6: error: variable or field 'calc' declared void
   29 | void calc(ll x){
      |      ^~~~
race.cpp:29:11: error: 'll' was not declared in this scope
   29 | void calc(ll x){
      |           ^~
race.cpp:54:6: error: variable or field 'DFS' declared void
   54 | void DFS(ll par, ll wpar, ll x){
      |      ^~~
race.cpp:54:10: error: 'll' was not declared in this scope
   54 | void DFS(ll par, ll wpar, ll x){
      |          ^~
race.cpp:54:18: error: 'll' was not declared in this scope
   54 | void DFS(ll par, ll wpar, ll x){
      |                  ^~
race.cpp:54:27: error: 'll' was not declared in this scope
   54 | void DFS(ll par, ll wpar, ll x){
      |                           ^~
race.cpp:91:1: error: 'll' does not name a type
   91 | ll best_path(ll n, ll k, ll H[][2], ll L[]){
      | ^~