이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second
using namespace std;
vector<vector<pair<int, int> > > adj;
int n, m, cost;
int find(int indx, int par = -1) {
// cout << indx << '\n';
int l = 0, r = adj[indx].size()-1;
for (int i = 0; i < adj[indx].size(); i++) {
if (adj[indx][i].ff == par) {
r--;
swap(adj[indx][i], adj[indx].back());
}
}
if (r == -1) return indx;
while (l < r) {
int mid = (l + r) / 2;
vector<int> q(m, 0);
for (int i = l; i <= mid; i++)
q[adj[indx][i].ss] = 1;
if (ask(q) != cost)
r = mid;
else
l = mid+1;
}
vector<int> q(m, 0);
q[adj[indx][l].ss] = 1;
if (ask(q) == cost)
return indx;
return find(adj[indx][l].ff, indx);
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
n = n, m = U.size();
adj.resize(N);
for (int i = 0; i < m; i++) {
adj[U[i]].pb({V[i], i});
adj[V[i]].pb({U[i], i});
}
vector<int> q(m, 0);
cost = ask(q);
answer(0, find(0));
}
컴파일 시 표준 에러 (stderr) 메시지
highway.cpp: In function 'int find(int, int)':
highway.cpp:19:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for (int i = 0; i < adj[indx].size(); 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... |