제출 #1195535

#제출 시각아이디문제언어결과실행 시간메모리
1195535agussHighway Tolls (IOI18_highway)C++20
5 / 100
524 ms327680 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #define dbg(x) cerr << #x << ": " << x << "\n"; vector<int> depth; vector<pair<int, int>> nah; vector<vector<int>> arr; map<int, map<int, int>> neh; void dfs(int node, int prev = -1){ for(int &i : arr[node]){ if(i == prev) continue; depth[i] = depth[node] + 1; nah.push_back({depth[i], neh[min(node, i)][max(node, i)]}); dfs(i, node); } } int maxdepth(int a, int b){ if(depth[a] > depth[b]) return a; return b; } void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) { arr.assign(N, vector<int>()); depth.assign(N, 0); int M = U.size(); for(int i = 0; i < (int)U.size(); i++){ if(U[i] > V[i]) swap(U[i], V[i]); neh[U[i]][V[i]] = i; arr[U[i]].push_back(V[i]); arr[V[i]].push_back(U[i]); } vector<int> vec(M, 0); long long x = ask(vec); dfs(0); for(int i = 0; i < M; i++){ if(nah[i].first == x / A){ vec[nah[i].second] = 1; if(ask(vec) != x){ answer(0, maxdepth(U[nah[i].second], V[nah[i].second])); return; } } } }
#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...