제출 #284030

#제출 시각아이디문제언어결과실행 시간메모리
284030milleniumEeeeHighway Tolls (IOI18_highway)C++14
0 / 100
19 ms3072 KiB
#include "highway.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define szof(s) (int)s.size()
#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;

void create(vector <int> &path) {
  for (int i = 0; i < m; i++) {
    w[i] = 0;
  }
  for (int edge : path) {
    w[edge] = 1;
  }
}

void dfs(int v, int par, vector <int> &path) {
  if (v != 0) {
    create(path);
    int dist = ask(w);
    if (dist == szof(path) * b) {
      S = 0, T = v;
    }
  }
  for (pii to : g[v]) {
    if (to.sc != par) {
      path.push_back(to.fr);
      dfs(to.sc, v, path);
      path.pop_back();
    }
  }
}

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);
  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]});
  }
  vector <int> path = {};
  dfs(0, -1, path);
  answer(S, T);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...