이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN=90005;
int n,m,par[MAXN];
vector <int> v[MAXN];
vector <pair<int,int> > vv;
map <pair<int,int>, int> r;
long long ANS;
void dfs (int x,int p,int l)
{
vv.push_back({l,x});
par[x]=p;
for (int i=0;i<v[x].size();i++)
{
if (v[x][i]!=p)
{
dfs(v[x][i],x,l+1);
}
}
}
void find_pair (int N, vector<int> U, vector<int> V, int A, int B)
{
n=N;
m=U.size();
vector<int> w;
w.resize(m);
ANS=ask(w);
for (int i=0;i<m;i++)
{
v[U[i]].push_back(V[i]);
v[V[i]].push_back(U[i]);
r[{U[i],V[i]}]=i;
r[{V[i],U[i]}]=i;
}
dfs(0,-1,1);
int low=0,high=vv.size(),mid,ans=-1;
while (low<=high)
{
for (int i=0;i<w.size();i++)
w[i]=0;
mid=(low+high)/2;
for (int i=mid;i<vv.size();i++)
{
int a=vv[i].second;
w[r[{a,par[a]}]]=1;
}
if (ask(w)!=ANS)
{
ans=vv[mid].second;
low=mid+1;
}
else
high=mid-1;
}
answer(0,ans);
}
컴파일 시 표준 에러 (stderr) 메시지
highway.cpp: In function 'void dfs(int, int, int)':
highway.cpp:14:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<v[x].size();i++)
~^~~~~~~~~~~~
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:40:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<w.size();i++)
~^~~~~~~~~
highway.cpp:43:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=mid;i<vv.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... |