Submission #290127

#TimeUsernameProblemLanguageResultExecution timeMemory
290127dandrozavrHighway Tolls (IOI18_highway)C++14
0 / 100
22 ms11384 KiB
#include "highway.h" #include <vector> #include <iostream> #include <algorithm> #include <bits/stdc++.h> #define TIME 1.0 * clock() / CLOCKS_PER_SEC using namespace std; #define pb push_back #define F first #define S second #define _ <<" "<< #define pii pair < int , int > const int N = 2e5 + 5; vector < pii > g[N]; vector < int > emp; int Len, a, b; void dfs(int v, int pr, int len){ // cout << v _ pr _ len << endl; if (!len){ answer(0, v); return; } vector < pii > vis; for (pii to : g[v]) if (to.F != pr) vis.pb(to); // for (auto i : vis) cout << i.F _ i.S << endl; // cout<<endl; if (vis.size() == 1){ dfs(vis[0].F, v, len - 1); return; } int l = 0, r = vis.size() - 1; while(l < r){ int mid = (l + r) >> 1; for (int i = 0; i <= mid; ++i) emp[vis[i].S] = 1; // cout << mid _ ask(emp) << endl; if (ask(emp) == Len * a) l = mid + 1; else r = mid; for (int i = 0; i < mid; ++i) emp[vis[i].S] = 0; } // cout<<endl; dfs(vis[l].F, v, len - 1); } void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) { a = A; b = B; int n = N; int m = U.size(); for (int i = 0; i < m; ++i){ int x = U[i]; int y = V[i]; g[x].pb({y, i}); g[y].pb({x, i}); } vector < int > vc(m, 0); emp = vc; Len = ask(vc) / A; if (Len == 0){ answer(0, 0); return; } dfs(0, -1, Len); // cout<<"BAD\n"; }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:50:9: warning: unused variable 'n' [-Wunused-variable]
   50 |     int n = N;
      |         ^
#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...