Submission #425173

#TimeUsernameProblemLanguageResultExecution timeMemory
425173PbezzHighway Tolls (IOI18_highway)C++14
5 / 100
333 ms28680 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back typedef pair<ll,ll> pii; const ll MAXN = 2e5+5; const ll INF = 1e9+7; int M,k;//k = menor distancia vector<vector<int>>adj(MAXN); map<pair<int,int>,int>mapi; bool stop=false; void dfs(ll node, ll p){if(stop)return; bool ok=false; for(auto u:adj[node]){if(stop)return; if(u==p)continue; std::vector<int> w(M); for(ll i=0;i<M;i++)w[i]=0; w[ mapi[{node,u}] ]=1; if(ask(w)>k){ dfs(u,node); ok=true; }if(stop)return; } if(ok==false){ answer(0,node); stop=true; } } void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) { M = U.size(); std::vector<int> w(M); for(ll i=0;i<M;i++)w[i]=0; k = ask(w); for(ll i=0;i<N;i++){ adj[U[i]].pb(V[i]); adj[V[i]].pb(U[i]); mapi[ {U[i],V[i]} ]=i; mapi[ {V[i],U[i]} ]=i; } dfs(0,-1); }
#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...