Submission #266761

#TimeUsernameProblemLanguageResultExecution timeMemory
266761Ruba_KHighway Tolls (IOI18_highway)C++14
0 / 100
11 ms768 KiB
#include "highway.h" #include<bits/stdc++.h> using namespace std; int d ; vector<int>adj[101]; bool indepth(int u , int p){ if(u == d)return true ; for(auto f : adj[u]){ if(f == p)continue ; if(indepth(f , u))return true ; } return false ; }int sz[101] , parent[101]; void dfs(int u , int p , int dd){ sz[u] = dd ; parent[u] = p; for(auto f : adj[u]){ if(f == p)continue ; dfs(f , u , dd + 1); } } int b[101]; void dfs2(int u, int p){ for(auto f : adj[u]){ if(f == p)continue ; if(indepth(f , u))dfs2(f , u) , b[f] = 1 ; } } void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) { int M = U.size(); for(int i = 0 ; i < M ; i ++) adj[U[i]].push_back(V[i]) , adj[V[i]].push_back(U[i]); dfs(0 , -1 , 0); int ans = 0 ; for (int j = 1; j <= N; ++j) { vector<int> w; memset(b , 0 , sizeof b); d = j ; dfs2(j , parent[j]); for(int i = 0 ; i < M ; i ++){ if(b[U[i]] + b[V[i]] == 2)w.push_back(1); else w.push_back(0); } long long toll = ask(w); if(toll == sz[j] * A){ ans = j ; break; } } answer(0, ans); }
#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...