제출 #800792

#제출 시각아이디문제언어결과실행 시간메모리
800792biank통행료 (IOI18_highway)C++11
0 / 100
17 ms2384 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; #define SIZE(x) (int)x.size() #define ll long long vector <vector <int>> adj; map <pair <int, int>, int> m; vector <int> h; int s = -1, t = -1; void DFS(ll dist, int u = 0, int p = -1) { int c = 0; for (int v:adj[u]) { if (c >= 2) { return; } if (v == p) { c++; continue; } h[m[{u,v}]] = 1; bool b = ask(h) > dist; h[m[{u,v}]] = 0; c += b; if (b) { DFS(dist, v, u); } if (c >= 2) { return; } } if (s == -1) { s = u; } else if (t == -1) { t = u; } else { cerr << "error: " << u << endl; } } void find_pair(int N, vector<int> U, vector<int> V, int A, int B) { if (A > B) { return; } adj.resize(N); int M = SIZE(U); h.assign(M, 0); for (int i=0; i<M; i++) { adj[V[i]].push_back(U[i]); adj[U[i]].push_back(V[i]); m[{V[i], U[i]}] = i; m[{U[i], V[i]}] = i; } DFS(ask(h)); 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...