# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
421512 | Sundavar | Highway Tolls (IOI18_highway) | C++14 | 3089 ms | 8584 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 <bits/stdc++.h>
#include "highway.h"
using namespace std;
typedef pair<int,int> pii;
struct node{
vector<pii> to;
int depth = 0;
bool was = false;
};
vector<node> graph;
void DFS(int curr){
graph[curr].was = true;
for(pii& a : graph[curr].to)
if(!graph[a.first].was)
graph[a.first].depth = graph[curr].depth +1, DFS(a.first);
graph[curr].was = false;
}
vector<pii> poss;
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
graph.resize(N);
int M = U.size();
for(int i = 0; i < M; i++){
graph[U[i]].to.push_back({V[i],i});
graph[V[i]].to.push_back({U[i],i});
}
DFS(0);
vector<int> s(M, 0);
int at = ask(s)/A;
for(int i = 0; i < N; i++)
if(graph[i].depth == at-1)
for(pii& a : graph[i].to)
if(graph[a.first].depth == at) poss.push_back(a);
while(poss.size() > 1){
s.assign(M, 0);
for(int i = 0; i < poss.size()/2; i++) s[poss[i].second] = 1;
if(ask(s) == (at-1)*A + B) poss.resize(poss.size()/2);
else{
vector<pii> uj;
for(int i = poss.size()/2; i < poss.size(); i++) uj.push_back(poss[i]);
poss = uj;
}
}
//cout<<0<<" "<<poss[0].first<<"\n";
answer(0, poss[0].first);
}
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... |