이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "highway.h"
using namespace std;
vector<vector <pair<int ,int>>> adj;
vector <pair<int ,int>> ver;
void dfs(int u ,int p=-1 ,int f=-1){
for(auto&e : adj[u]) if(e.first != p)
dfs(e.first ,u ,e.second);
ver.push_back({u ,f});
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
assert(U.size() == N-1);
adj.resize(N);
for(int i=0; i<N-1; i++){
adj[U[i]].push_back({V[i] ,i});
adj[V[i]].push_back({U[i] ,i});
}
int S ,T;
long long emp = ask(vector<int>(N-1 ,0));
ver.clear() ,dfs(0) ,ver.pop_back();
int st = 0 ,en = N-1 ,mid;
while(st <= en){
mid = (st+en)>>1;
vector <int> t(N-1 ,0);
fill(t.begin()+st ,t.begin()+en+1 ,1);
if(ask(t) != emp)
en = mid-1;
else
st = mid+1;
}
S = st;
ver.clear() ,dfs(S) ,ver.pop_back();
st = 0 ,en = N-1 ,mid;
while(st <= en){
mid = (st+en)>>1;
vector <int> t(N-1 ,0);
fill(t.begin()+st ,t.begin()+en+1 ,1);
if(ask(t) != emp)
en = mid-1;
else
st = mid+1;
}
T = st;
answer(S ,T);
}
컴파일 시 표준 에러 (stderr) 메시지
In file included from /usr/include/c++/9/cassert:44,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
from highway.cpp:1:
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:15:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
15 | assert(U.size() == N-1);
| ~~~~~~~~~^~~~~~
highway.cpp:38:26: warning: right operand of comma operator has no effect [-Wunused-value]
38 | st = 0 ,en = N-1 ,mid;
| ^
# | 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... |