제출 #1148160

#제출 시각아이디문제언어결과실행 시간메모리
1148160Kaztaev_Alisher통행료 (IOI18_highway)C++20
0 / 100
226 ms327680 KiB
#include "highway.h" #include <bits/stdc++.h> #define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout) #define all(a) a.begin() , a.end() #define F first #define S second using namespace std; using ll = long long; const ll N = 2e5+5 , inf = 2e9 + 7; const ll INF = 1e18 , mod = 1e9+7; int dep[N] , road[N]; vector<pair<int,int>> g[N]; void dfs(int v, int p , int cost){ for(auto x : g[v]){ int to = x.S; if(to != p) { road[to] = x.F; dep[to] = dep[v]+cost; dfs(to,v,cost); } } } void find_pair(int n, vector<int> U, vector<int> V, int A, int B) { vector<int> w; for(int i = 0; i < U.size(); i++){ g[U[i]].push_back({i,V[i]}); g[V[i]].push_back({i,U[i]}); w.push_back(0); } vector<int> vec; dfs(0,-1,A); int cost1 = ask(w); for(int i = 0; i < n; i++){ if(cost1 == dep[i]){ vec.push_back(i); } } int l = 0 , r = vec.size()-1; while(l <= r){ if(l == r){ answer(0,l); return; } int md = (l+r) >> 1; for(int i : vec) { if(i <= md){ w[road[i]] = 0; } else { w[road[i]] = 1; } } int cost = ask(w); if(cost != cost1){ l = md+1; } else { r = md; } } answer(0, N - 1); }
#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...