# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1074651 | wood | Highway Tolls (IOI18_highway) | C++17 | 75 ms | 9252 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;
typedef long long ll;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vi vector<int>
#define vp32 vector<p32>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MOD %1000000007
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//never guess
//never debug without reviewing code
//never try adding ones or substracting them
//only step by step debug when necessay
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
int n = N, m = U.size();
vp32 adj[n];
int vertex[m];
for(int i = 0; i<m; i++){
adj[U[i]].eb(V[i],i);
adj[V[i]].eb(U[i],i);
}
queue<p32> q;
q.emplace(0,-1);
p32 depth[n]; memset(depth,0,sizeof depth); depth[0] = p32(1,-1);
while(!q.empty()){
p32 x = q.front();
q.pop();
for(p32 ii : adj[x.fi]){
if(!depth[ii.fi].fi){
depth[ii.fi].fi = depth[x.fi].fi+1;
depth[ii.fi].se = ii.se;
q.push(ii);
vertex[ii.se] = ii.fi;
}
}
}
vi w(m);
ll d = ask(w)/A;
vector<int> v;
for(int i = 0; i<n ;i++){
if(depth[i].fi==d+1) v.pb(depth[i].se);
}
int l = -1, r = v.size()-1;
while(r-l>1){
int mid = (r+l)/2;
vi soel(m);
for(int i = l+1; i<=mid; i++){
soel[v[i]] = 1;
}
if(ask(soel)==d*A) l = mid;
else r = mid;
}
answer(0,vertex[v[r]]);
}
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... |