이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1<<17;
using ll = long long;
int m;
vector<int> c;
vector<int> res;
vector<array<int, 2>> g[maxn];
int D, a, b;
void dfs(int v, int p, int h = 0) {
for(auto [i, id] : g[v]) if(i != p) {
if(h+1 == D) c.push_back(id), res.push_back(i);
dfs(i, v, h+1);
}
}
bool go(vector<int> c, int p) {
vector<int> w(m);
for(int i = 0; i <= p; i++) w[c[i]] = 1;
return ask(w) == a*1ll*D;
}
bool gob(vector<int> c, int p) {
vector<int> w(m);
for(int i = 0; i <= p; i++) w[c[i]] = 1;
return ask(w) == b*1ll*D;
}
void find_pair(int n, std::vector<int> U, std::vector<int> V, int A, int B) {
a = A, b = B;
m = U.size();
if(m != n-1) return;
int s3 = 1;
for(int i = 0; i < U.size(); i++) {
s3 &= U[i] == i && V[i] == i+1;
g[U[i]].push_back({V[i], i});
g[V[i]].push_back({U[i], i});
}
D = ask(vector<int>(m))/A;
if(s3) {
for(int i = 0; i < m; i++)
c.push_back(i);
int ans = -1;
for(int z = 1<<17; z>>=1;)
if(ans+z < c.size() && go(c, ans+z)) ans += z;
int ans1 = ans++;
for(int z = 1<<17; z>>=1;)
if(ans1+z < c.size() && !gob(c, ans1+z)) ans1 += z;
answer(ans, ans1+2);
return;
}
dfs(0, 0, 0);
int ans = -1;
for(int z = 1<<17; z>>=1;)
if(ans+z < c.size() && go(c, ans+z)) ans += z;
answer(0, res[ans+1]);
}
컴파일 시 표준 에러 (stderr) 메시지
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:33:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < U.size(); i++) {
~~^~~~~~~~~~
highway.cpp:44:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(ans+z < c.size() && go(c, ans+z)) ans += z;
~~~~~~^~~~~~~~~~
highway.cpp:47:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(ans1+z < c.size() && !gob(c, ans1+z)) ans1 += z;
~~~~~~~^~~~~~~~~~
highway.cpp:54:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(ans+z < c.size() && go(c, ans+z)) ans += z;
~~~~~~^~~~~~~~~~
# | 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... |