# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
463670 | tomsyd | Highway Tolls (IOI18_highway) | C++17 | 279 ms | 262148 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
vector<int> nodes;
void dfs(int node, int prev){
for (int i:adj[node]){
if (i != prev){
dfs(i,node);
}
}
nodes.emplace_back(node);
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
int M = U.size();
nodes.clear();
adj = vector<vector<int>>(N);
for (int i=0; i<M; ++i){
adj[U[i]].emplace_back(V[i]);
adj[V[i]].emplace_back(U[i]);
}
dfs(0,-1);
vector<int> query;
for (int i=0; i<N; ++i) query.emplace_back(1);
int init = ask(query), crt = nodes[nodes.size()-1];
for (int j=0; j<nodes.size()-1; ++j){
query[nodes[j]] = 0;
if (ask(query) != init){
crt = nodes[j];
break;
}
query[nodes[j]] = 1;
}
cout << crt;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |