#include <bits/stdc++.h>
#include "highway.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ALL(v) (v).begin(), (v).end()
#define MASK(i) (1LL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng(1);
ll rngesus(ll l, ll r){return ((ull) rng()) % (r - l + 1) + l;}
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll LASTBIT(ll mask){return mask & (-mask);}
ll pop_cnt(ll mask){return __builtin_popcountll(mask);}
ll ctz(ll mask){return __builtin_ctzll(mask);}
ll clz(ll mask){return __builtin_clzll(mask);}
ll logOf(ll mask){return 63 - clz(mask);}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b){a = b; return true;}
return false;
}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b){a = b; return true;}
return false;
}
template <class T>
void printArr(T& a, string separator = " ", string finish = "\n", ostream& out = cout){
for(auto i: a) out << i << separator;
out << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
const int N = 1e5 + 69;
int n, m;
vector<pair<int, int>> graph[N];
int h[N];
void dfs(int u, int p, vector<int> &topo){
for(pair<int, int> v: graph[u]) if (v.first != p){
h[v.first] = h[u] + 1;
dfs(v.first, u, topo);
topo.push_back(v.second);
}
}
void find_pair(int _n, vector<int> U, vector<int> V, int A, int B) {
n = _n, m = U.size();
for(int i = 0; i<n; ++i) graph[i].clear();
for(int i = 0; i<m; ++i){
int u = U[i], v = V[i];
graph[u].push_back({v, i});
graph[v].push_back({u, i});
}
ll initial = ask(vector<int>(m));
vector<int> topo;
dfs(0, 0, topo);
int l= 0, r = topo.size() - 1;
while(l < r){
int mid = (l + r) >> 1;
vector<int> w(m);
for(int i = 0; i<=mid; ++i) w[topo[i]] = 1;
if (ask(w) > initial) r = mid;
else l = mid + 1;
}
int x;
if (h[U[l]] > h[V[l]]) x = U[l];
else x = V[l];
topo.clear();
dfs(x, x, topo);
l= 0, r = topo.size() - 1;
while(l < r){
int mid = (l + r) >> 1;
vector<int> w(m);
for(int i = 0; i<=mid; ++i) w[topo[i]] = 1;
if (ask(w) > initial) r = mid;
else l = mid + 1;
}
int y;
if (h[U[l]] == initial / A) y = h[U[l]];
else y = h[V[l]];
answer(x, y);
}
// int main(void){
// ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// int n, m; cin >> n >> m;
// vector<int> U, V;
// for(int i = 0; i<m; ++i){
// int u, v; cin >> u >> v;
// U.push_back(u); V.push_back(v);
// }
// int a, b; cin >> a >> b;
// find_pair(n, U, V, a, b);
// return 0;
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
3016 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3064 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
4940 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
3072 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
233 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
181 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |