제출 #162816

#제출 시각아이디문제언어결과실행 시간메모리
162816Minnakhmetov통행료 (IOI18_highway)C++14
12 / 100
387 ms262144 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; #define ll long long struct E { int to, i; }; const int N = 1e5 + 5; vector<E> g[N], ord; void dfs(int node, int anc) { for (E e : g[node]) { if (e.to != anc) { ord.push_back(e); dfs(e.to, node); } } } void find_pair(int n, vector<int> u, vector<int> v, int a, int b) { int m = u.size(); for (int i = 0; i < m; i++) { g[u[i]].push_back({v[i], i}); g[v[i]].push_back({u[i], i}); } dfs(0, -1); // for (E e : ord) { // cout << e.to << " "; // } // cout << "\n"; ll mx = ask(vector<int>(m, 1)); int l = 0, r = ord.size(); while (r - l > 1) { int p = (l + r) >> 1; vector<int> w(m); for (int i = 0; i < p; i++) w[ord[i].i] = 1; if (ask(w) == mx) r = p; else l = p; } answer(0, ord[r - 1].to); }
#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...