제출 #284041

#제출 시각아이디문제언어결과실행 시간메모리
284041milleniumEeee통행료 (IOI18_highway)C++14
5 / 100
20 ms3072 KiB
#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 <int> 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(y[i]);
    g[y[i]].push_back(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, -1);
  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

*/
#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...