Submission #378074

# Submission time Handle Problem Language Result Execution time Memory
378074 2021-03-15T22:48:59 Z MilosMilutinovic Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5;

vector<vector<pair<int, int>>> g(N);
vector<bool> esc(N, false);
vector<int> dp(N, 0);

void Dfs(int u, int p) {
  if (esc[u]) {
    return 0;
  }
  for (auto v : g[u]) {
    if (v.first == p) {
      continue;
    }
    Dfs(v.first, u);
  }
  vector<pair<int, int>> id;
  for (auto v : g[u]) {
    if (v.first != p) {
      id.emplace_back(dp[v.first], v.second);
    }
  }
  sort(id.begin(), id.end(), [&](pair<int, int> i, pair<int, int> j) {
    return i.first + i. second < j.first + j.second;
  });
  assert((int) id.size() >= 2);
  dp[u] = id[1];
}

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
  for (int i = 0; i < m; i++) {
    g[r[i][0]].emplace_back(r[i][1], l[i]);
    g[r[i][1]].emplace_back(r[i][0], l[i]);
  }
  for (int i = 0; i < k; i++) {
    esc[p[i]] = true;
  }
  Dfs(0, -1);
  return dp[0];
}

Compilation message

crocodile.cpp: In function 'void Dfs(int, int)':
crocodile.cpp:14:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   14 |     return 0;
      |            ^
crocodile.cpp:32:15: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} in assignment
   32 |   dp[u] = id[1];
      |               ^