Submission #999294

#TimeUsernameProblemLanguageResultExecution timeMemory
999294UnforgettableplHighway Tolls (IOI18_highway)C++17
12 / 100
205 ms262144 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(),x.end() long long ask(const std::vector<int> &w); void answer(int s, int t); void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) { vector<vector<pair<int,int>>> adj(N); for(int i=0;i<U.size();i++){ adj[U[i]].emplace_back(V[i],i); adj[V[i]].emplace_back(U[i],i); } vector<int> pedge(N); vector<int> depth(N); function<void(int,int,int,int)> dfs = [&](int x,int p,int dep,int par){ depth[x]=dep; pedge[x]=par; for(auto&i:adj[x])if(i.first!=p)dfs(i.first,x,dep+1,i.second); }; dfs(0,-1,0,-1); int M = U.size(); auto base = ask(vector<int>(M)); auto basedep = base/((long long)A); vector<int> sus; for(int i=0;i<N;i++)if(depth[i]==basedep)sus.emplace_back(i); while(sus.size()>1){ int mid = (sus.size())/2; vector<int> left,right; for(int i=0;i<mid;i++)left.emplace_back(sus[i]); for(int i=mid;i<sus.size();i++)right.emplace_back(sus[i]); vector<int> w(M); for(int&i:left)w[pedge[i]]=1; auto ans = ask(w); if(ans!=base)sus=left; else sus=right; } answer(0, sus[0]); }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i=0;i<U.size();i++){
      |              ~^~~~~~~~~
highway.cpp:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for(int i=mid;i<sus.size();i++)right.emplace_back(sus[i]);
      |                 ~^~~~~~~~~~~
#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...