Submission #411248

# Submission time Handle Problem Language Result Execution time Memory
411248 2021-05-24T20:21:05 Z LouayFarah Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"
#include "crocodile.h"
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair

void dfs(vector<pair<int, int>> tree[], vector<int> &dist, vector<int> &len, int u, int e)
{
    for(auto v: tree[u])
    {
        if(v.first==e)
            continue;
        dist[v.fi] = dist[u] + v.se;
        len[v.fi] = len[u] + 1;
        dfs(tree, dist, len, v.fi, u);
    }
}

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[])
{
    vector<pair<int, int>> tree[n];
    for(int i = 0; i<m; i++)
    {
        tree[r[i][0]].pb(mp(r[i][1], l[i]));
        tree[r[i][1]].pb(mp(r[i][0], l[i]));
    }

    vector<int> dist(n, 0);
    vector<int> len(n, 0);
    dfs(tree, dist, len, 0, -1);

    int res = 0;

    vector<pair<int, int>> v;
    for(int i = 0; i<k; i++)
    {
        v.pb(mp(dist[p[i]], len[p[i]]));
    }

    sort(all(v));

    for(int i = 0; i<k; i++)
    {
        if(v[i].se<i+1)
        {
            res = v[i].fi;
            break;
        }
    }

    return res;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:43:10: error: 'all' was not declared in this scope
   43 |     sort(all(v));
      |          ^~~