| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 293467 | Muhammetali | Highway Tolls (IOI18_highway) | C++11 | 0 ms | 0 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>
#define mp make_pair
#define sz(x) (int)(x).size()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define REP(i,a) for (int i = 0; i < (a); ++i)
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define trav(a,x) for (auto& a: x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
const int N=2e5+1;
template<class T>bool tmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool tmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vl v,ab,coun;
vector<pair<ll,ll>> par[N];
ll a,b,jem[N]={INT_MAX};
void dfs(ll k,ll gos=0)
{
REP(i,sz(par[k]))
{
if (jem[par[k][i].first]>gos+ab[v[par[k][i].second]])
{
jem[par[k][i].first]=gos+ab[v[par[k][i].second]];
dfs(par[k][i].first,gos+ab[v[par[k][i].second]]);
}
}
}
void sum(ll toll)
{
dfs(1);
REP(i,coun.size())
{
if (coun[i]==1)continue;
if (jem[coun[i]]!=toll)count.erase(i,1);
}
}
void recur(int M,int sum=0)
{
if (sum==M)
{
sum(ask(v));
return;
}
FOR(i,0,1)
{
v.push_back(i);
recur(M,sum+1);
v.pop_back();
}
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
int M = U.size();
ab.push_back(A);
ab.push_back(B);
bool bo[N]={0};
REP(i,sz(U))
{
if (bo[U[i]]==0)
{
bo[U[i]]=1;
coun.push_back(U[i]);
}
if (bo[V[i]]==0)
{
bo[V[i]]=1;
coun.push_back(V[i]);
}
par[U[i]].push_back({V[i],i});
par[V[i]].push_back({U[i],i});
}
recur(M);
answer(count[0],count[1]);
}
