이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
long long ask(const std::vector<int> &w);
void answer(int s, int t);
const ll NP=1e5;
vector<pair<ll,ll>> ma[NP],tmp;
vector<int> w;
ll mi,a,b;
int dfs(int x,int p=-1)
{
tmp.clear();
for(auto i:ma[x])
{
if(i.second!=p)
{
tmp.pb(i);
}
}
int s=-1;
int e=tmp.size();
while(s+1<e)
{
int mid=(s+e)/2;
for(int j=s+1;j<=mid;j++)
w[tmp[j].first]=1;
ll cost=ask(w);
for(int j=s+1;j<=mid;j++)
w[tmp[j].first]=0;
if((cost>mi)) // edge is inside
{
e=mid;
}
else{
s=mid;
}
}
if(e==(tmp.size()))
{
// no edge
return x;
}
else
{
return dfs(tmp[e].second,x);
}
}
void find_pair(int n, std::vector<int> u, std::vector<int> v, int A, int B)
{
int m=u.size();
w.resize(m,0);
a=A;
b=B;
mi=ask(w);
for(int i=0;i<m;i++)
{
ma[u[i]].pb({i,v[i]});
ma[v[i]].pb({i,u[i]});
}
answer(0,dfs(0));
}
컴파일 시 표준 에러 (stderr) 메시지
highway.cpp: In function 'int dfs(int, int)':
highway.cpp:39:6: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | if(e==(tmp.size()))
| ~^~~~~~~~~~~~~~
# | 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... |