This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "highway.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define szof(s) (int)s.size()
#define ll long long
#define fr first
#define sc second
using namespace std;
const int N = 90004;
vector <int> g[N];
int x[N], y[N];
int n, m, a, b;
int S, T;
vector <int> w;
map <pii, bool> mp;
int dfs(int v, int par) {
for (int to : g[v]) {
if (to == par) {
continue;
}
if (mp.count({v, to})) {
return dfs(to, v);
}
}
return v;
}
void find_pair(int NN, vector<int> U, vector<int> V, int A, int B) {
n = NN;
m = U.size();
a = A;
b = B;
w.resize(m, 1);
for (int i = 0; i < m; i++) {
x[i] = U[i];
y[i] = V[i];
g[x[i]].push_back(y[i]);
g[y[i]].push_back(x[i]);
}
ll before = ask(w);
for (int i = 0; i < m; i++) {
w[i] = 0;
int nxt = ask(w);
if (nxt < before) {
w[i] = 0;
before = nxt;
} else {
w[i] = 1;
}
}
for (int i = 0; i < m; i++) {
if (w[i] == 0) {
mp[{x[i], y[i]}] = 1;
mp[{y[i], x[i]}] = 1;
}
}
S = 0;
T = dfs(0, -1);
answer(S, T);
}
/*
10
9
4
9
4
1
4 6
9 5
5 0
8 2
1 7
7 4
4 2
2 9
3 9
*/
# | 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... |