Submission #411243

# Submission time Handle Problem Language Result Execution time Memory
411243 2021-05-24T20:06:40 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;

void dfs(vector<pair<int, int>> tree[], vector<int> &dist, int u, int e)
{
    for(auto v: tree[u])
    {
        if(v.fi==e)
            continue;
        dist[v.fi] = dist[u] + v.se;
        dfs(tree, dist, 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);
    dfs(tree, dist, 0, -1);

    int maxi = 0;
    for(int i = 0; i<n; i++)
    {
        maxi = max(maxi, dist[i]);
    }

    return maxi;
}

Compilation message

crocodile.cpp: In function 'void dfs(std::vector<std::pair<int, int> >*, std::vector<int>&, int, int)':
crocodile.cpp:9:14: error: 'struct std::pair<int, int>' has no member named 'fi'
    9 |         if(v.fi==e)
      |              ^~
crocodile.cpp:11:16: error: 'struct std::pair<int, int>' has no member named 'fi'
   11 |         dist[v.fi] = dist[u] + v.se;
      |                ^~
crocodile.cpp:11:34: error: 'struct std::pair<int, int>' has no member named 'se'
   11 |         dist[v.fi] = dist[u] + v.se;
      |                                  ^~
crocodile.cpp:12:27: error: 'struct std::pair<int, int>' has no member named 'fi'
   12 |         dfs(tree, dist, v.fi, u);
      |                           ^~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:21:23: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
   21 |         tree[r[i][0]].pb(mp(r[i][1], l[i]));
      |                       ^~
crocodile.cpp:21:26: error: 'mp' was not declared in this scope; did you mean 'm'?
   21 |         tree[r[i][0]].pb(mp(r[i][1], l[i]));
      |                          ^~
      |                          m
crocodile.cpp:22:23: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
   22 |         tree[r[i][1]].pb(mp(r[i][0], l[i]));
      |                       ^~