이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N,A,B,M,depthT;
vector<vector<pair<int,int>>> adj;
vector<pair<int,int>> pos;
void dfs(int u, int depth, int p) {
// cout << u << " " << pos.size() << "\n";
for (auto e: adj[u]) {
int v,k; tie(v,k) = e;
if (v == p) continue;
if (depth+1 == depthT) pos.push_back(e);
else dfs(v,depth+1,u);
}
}
void find_pair(int tempN, std::vector<int> U, std::vector<int> V, int tempA, int tempB) {
N = tempN; A = tempA; B = tempB; M = U.size(); adj.resize(N);
for (int i = 0; i < M; i++) {
adj[U[i]].push_back(make_pair(V[i],i));
adj[V[i]].push_back(make_pair(U[i],i));
}
vector<int> w(M,0);
depthT = ask(w)/A;
dfs(0,0,-1);
while (pos.size() > 1) {
int mid = pos.size()/2;
for (int i = 0; i < mid; i++) w[pos[i].second] = 0;
for (int i = mid; i < pos.size(); i++) w[pos[i].second] = 1;
if (ask(w) == (ll)depthT*A) {
pos.erase(pos.begin()+mid,pos.end());
}
else {
pos.erase(pos.begin(),pos.begin()+mid);
}
}
//cout << pos[0].first << "\n";
answer(0, pos[0].first);
}
컴파일 시 표준 에러 (stderr) 메시지
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:39:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = mid; i < pos.size(); i++) w[pos[i].second] = 1;
~~^~~~~~~~~~~~
# | 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... |