이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=1e5+5;
int id[nx], t, vs[nx], res[nx], l, r, h;
vector<pair<int, int>> d[nx];
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
vector<int> qs(N-1);
for (int i=0; i<U.size(); i++) d[U[i]].push_back({V[i], i}), d[V[i]].push_back({U[i], i});
ll length=ask(qs)/A;
queue<int> q;
q.push(0);
vs[0]=1;
while (!q.empty())
{
int u=q.front();
q.pop();
for (auto [v, idx]:d[u]) if (!vs[v]) res[t]=v, id[t++]=idx, vs[v]=1, q.push(v);
}
l=0, r=N-1;
while (l<r)
{
int md=(l+r)/2;
for (int i=0; i<N-1; i++) qs[i]=0;
for (int i=0; i<=md; i++) qs[id[i]]=1;
if (ask(qs)/B==length) r=md;
else l=md+1;
}
int h=res[l];
t=0;
for (int i=0; i<N; i++) vs[i]=0;
q.push(h);
vs[h]=1;
while (!q.empty())
{
int u=q.front();
q.pop();
for (auto [v, idx]:d[u]) if (!vs[v]) res[t]=v, id[t++]=idx, vs[v]=1, q.push(v);
}
l=0, r=N-1;
while (l<r)
{
int md=(l+r)/2;
for (int i=0; i<N-1; i++) qs[i]=0;
for (int i=0; i<=md; i++) qs[id[i]]=1;
if (ask(qs)/B==length) r=md;
else l=md+1;
}
answer(h, res[l]);
}
컴파일 시 표준 에러 (stderr) 메시지
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for (int i=0; i<U.size(); i++) d[U[i]].push_back({V[i], i}), d[V[i]].push_back({U[i], 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... |