이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int n, m;
ll dis;
vector<int> G[N], U, V;
int bound;
vector<int> vis;
int mk[N];
void BFS(int u){
mk[u] = 1;
int adj;
vis.pb(u);
int po = 0;
while(po < vis.size()){
for(int ed : G[ vis[po] ]){
if(ed >= bound)
continue;
adj = U[ed] ^ V[ed] ^ vis[po];
if(mk[adj])
continue;
vis.pb(adj);
}
po++;
}
}
int Solve(int u){
memset(mk, 0, sizeof mk);
V.clear();
BFS(u);
reverse(vis.begin(), vis.end());
int sz = vis.size();
int lw = 0, hg = sz, mid;
while(lw + 1 < hg){
mid = (lw + hg) >> 1;
memset(mk, 0, sizeof mk);
for(int i = 0; i < mid; i++)
mk[vis[i]] = 1;
vector<int> w;
for(int i = 0; i < m; i++)
w.pb(mk[U[i]] || mk[V[i]] || (i > bound));
if(ask(w) == dis)
lw = mid;
else
hg = mid;
}
return vis[lw];
}
void find_pair(int _n, vector<int> _U, vector<int> _V, int A, int B) {
n = _n;
U = _U;
V = _V;
m = U.size();
for(int i = 0; i < m; i++) G[U[i]].pb(i), G[V[i]].pb(i);
vector<int> w(m, 0);
dis = ask(w);
{
int lw = 0, hg = m;
int mid;
while(lw + 1 < hg){
mid = (lw + hg) >> 1;
vector<int> as(mid, 0);
as.resize(m, 1);
if(ask(as) == dis)
hg = mid;
else
lw = mid;
}
bound = lw;
}
int u = U[bound];
int v = V[bound];
answer(Solve(u), Solve(v));
// int M = U.size();
// for (int j = 0; j < 50; ++j) {
// std::vector<int> w(M);
// for (int i = 0; i < M; ++i) {
// w[i] = 0;
// }
// long long toll = ask(w);
// }
// answer(0, N - 1);
}
컴파일 시 표준 에러 (stderr) 메시지
highway.cpp: In function 'void BFS(int)':
highway.cpp:29:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | while(po < vis.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... |