Submission #292081

#TimeUsernameProblemLanguageResultExecution timeMemory
292081zoooma13Highway Tolls (IOI18_highway)C++14
51 / 100
216 ms13904 KiB
#include <bits/stdc++.h> #include "highway.h" using namespace std; vector<vector <pair<int ,int>>> adj; vector <pair<int ,int>> ver; void dfs(int u ,int p=-1 ,int f=-1){ for(auto&e : adj[u]) if(e.first != p) dfs(e.first ,u ,e.second); ver.push_back({u ,f}); } void find_pair(int N, vector<int> U, vector<int> V, int A, int B) { assert(U.size() == N-1); adj.resize(N); for(int i=0; i<N-1; i++){ adj[U[i]].push_back({V[i] ,i}); adj[V[i]].push_back({U[i] ,i}); } int S ,T; long long emp = ask(vector<int>(N-1 ,0)); ver.clear() ,dfs(0) ,ver.pop_back(); int st = 0 ,en = N-1 ,mid; while(st <= en){ mid = (st+en)>>1; vector <int> t(N-1 ,0); for(int i=st; i<=mid; i++) t[ ver[i].second ] = 1; if(ask(t) != emp) en = mid-1; else st = mid+1; } S = ver[st].first; ver.clear() ,dfs(S) ,ver.pop_back(); st = 0 ,en = N-1 ,mid; while(st <= en){ mid = (st+en)>>1; vector <int> t(N-1 ,0); for(int i=st; i<=mid; i++) t[ ver[i].second ] = 1; if(ask(t) != emp) en = mid-1; else st = mid+1; } T = ver[st].first; answer(S ,T); }

Compilation message (stderr)

In file included from /usr/include/c++/9/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from highway.cpp:1:
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:15:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |     assert(U.size() == N-1);
      |            ~~~~~~~~~^~~~~~
highway.cpp:39:26: warning: right operand of comma operator has no effect [-Wunused-value]
   39 |     st = 0 ,en = N-1 ,mid;
      |                          ^
#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...