이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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],vec;
void dfs(int nod,int t)
{
for(auto it:g[nod]){
if (it.first!=nod){
vec.push_back(it);
dfs(it.first,nod);
}
}
}
int calc(ll sum,ll b)
{
int st=0,dr=vec.size()-1,mij,i;
while(st<dr){
mij=(st+dr)/2;
for(i=1;i<vec.size();i++)
if (i<=mij)
w[vec[i].second]=1;
else
w[vec[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>v,int a,int b)
{
int m=u.size(),i;
for(i=0;i<m;i++){
g[u[i]].push_back(make_pair(v[i],i));
g[v[i]].push_back(make_pair(u[i],i));
}
w.assign(m,0);
ll sum=ask(w)/a;
int root=0;
for(i=0;i<2;i++){
vec.clear();
vec.push_back(make_pair(0,-1));
dfs(root,-1);
int nr=calc(sum,b);
root=ans[i]=vec[nr].first;
}
answer(ans[0],ans[1]);
}
컴파일 시 표준 에러 (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<vec.size();i++)
| ~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |