Submission #369129

#TimeUsernameProblemLanguageResultExecution timeMemory
369129denkendoemeerHighway Tolls (IOI18_highway)C++14
0 / 100
175 ms262148 KiB
#include<bits/stdc++.h> #include "highway.h" #define ll long long using namespace std; int ans[2]; vector<int>w; vector<pair<int,int>>g[100005],v; void dfs(int nod,int t) { for(auto it:g[nod]){ if (it.first!=nod){ v.push_back(it); dfs(it.first,nod); } } } int calc(ll sum,ll b) { int st=0,dr=v.size()-1,mij,i; while(st<dr){ mij=(st+dr)/2; for(i=1;i<v.size();i++) if (i<=mij) w[v[i].second]=1; else w[v[i].second]=0; if (ask(w)==sum*b) dr=mij; else st=mij+1; } return st; } void find_pair(int n,vector<int>u,vector<int>y,int a,int b) { int m=u.size(),i; for(i=0;i<m;i++){ g[u[i]].push_back(make_pair(y[i],i)); g[y[i]].push_back(make_pair(u[i],i)); } w.assign(m,0); ll sum=ask(w)/a; int root=0; for(i=0;i<1;i++){ v.clear(); v.push_back(make_pair(0,-1)); dfs(root,-1); int nr=calc(sum,b); root=ans[i]=v[nr].first; } answer(ans[0],ans[1]); }

Compilation message (stderr)

highway.cpp: In function 'int calc(long long int, long long int)':
highway.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(i=1;i<v.size();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...