Submission #284040

# Submission time Handle Problem Language Result Execution time Memory
284040 2020-08-26T14:46:12 Z milleniumEeee Highway Tolls (IOI18_highway) C++14
Compilation error
0 ms 0 KB
#include "highway.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define szof(s) (int)s.size()
#define ll long long
#define fr first
#define sc second

using namespace std;

const int N = 90004;
vector <pii> g[N];
int x[N], y[N];
int n, m, a, b;
int S, T;
vector <int> w;

map <pii, bool> mp;

int dfs(int v, int par) {
  for (int to : g[v]) {
    if (to == par) {
      continue;
    }
    if (mp.count({v, to})) {
      return dfs(to, v);
    }
  }
  return v;
}

void find_pair(int NN, vector<int> U, vector<int> V, int A, int B) {
  n = NN;
  m = U.size();
  a = A;
  b = B;
  w.resize(m, 1);
  for (int i = 0; i < m; i++) {
    x[i] = U[i];
    y[i] = V[i];
    g[x[i]].push_back({i, y[i]});
    g[y[i]].push_back({i, x[i]});
  }
  ll before = ask(w);
  for (int i = 0; i < m; i++) {
    w[i] = 0;
    int nxt = ask(w);
    if (nxt < before) {
      w[i] = 0;
      before = nxt;
    } else {
      w[i] = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    if (w[i] == 0) {
      mp[{x[i], y[i]}] = 1;
      mp[{y[i], x[i]}] = 1;
    }
  }
  S = 0;
  T = dfs(0);
  answer(S, T);
}

/*

10
9
4
9
4
1
4 6
9 5
5 0
8 2
1 7
7 4
4 2
2 9
3 9

*/

Compilation message

highway.cpp: In function 'int dfs(int, int)':
highway.cpp:21:20: error: cannot convert 'std::pair<int, int>' to 'int' in initialization
   21 |   for (int to : g[v]) {
      |                    ^
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:62:12: error: too few arguments to function 'int dfs(int, int)'
   62 |   T = dfs(0);
      |            ^
highway.cpp:20:5: note: declared here
   20 | int dfs(int v, int par) {
      |     ^~~