#include "highway.h"
#include <bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define pb push_back
#define pf push_front
#define sz size()
#define bc back()
#define pob pop_back()
#define pof pop_front()
#define fr first
#define sc second
using namespace std;
const ll N=2e5+7;
const ll inf=1e18;
vector<vector<array<ll,2>>> g(N), g2(N);
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
ll M = V.sz;
ll s, t, rt;
ll n = N;
vll v, u;
ll i;
for(auto i : V) v.pb(i);
for(auto i : U) u.pb(i);
vector<int> w(M, 0);
ll x = ask(w);
for(i=0;i<M;i++){
g[v[i]].pb({u[i], i});
g[u[i]].pb({v[i], i});
}
{//getting vertex on the path
ll l = 0, r = n;
while(l + 1 < r){
ll m = (l + r) / 2;
if(r - l > 60000) m = 60000;
w.assign(M, 0);
for(i=0;i<m;i++){
for(auto [to, r] : g[i]) w[r] = 1;
}
ll y = ask(w);
if(y == x) l = m;
else r = m;
}
rt = r;
}
vll p(n), d(n);
vll pr(n), tour;
vector<vll> dd(n);
auto bfs = [&](ll s){
for(i=0;i<n;i++){
dd[i].clear();
d[i] = inf;
pr[i] = p[i] = -1;
}
queue<ll> q;
q.push(s);
d[s] = 0;
while(q.size()){
ll x = q.front();
q.pop();
dd[d[x]].pb(x);
for(auto [to, r] : g[x]){
if(d[to] > d[x] + 1){
d[to] = d[x] + 1 ;
pr[to] = r;
p[to] = x;
q.push(to);
}
}
}
tour.clear();
for(i=0;i<n;i++){
for(auto j : dd[i]) tour.pb(j);
}
};
auto calc = [&](ll rt){
bfs(rt);
//~ cout<<rt<<endl;
ll l = 0, r = n;
while(l + 1 < r){
ll m = (l + r) / 2;
if(r - l > 60000) m = 60000;
w.assign(M, 1);
//~ cout<<m<<endl;
for(i=1;i<m;i++) {
w[pr[tour[i]]] = 0;
//~ cout<<v[pr[tour[i]]]<<' '<<u[pr[tour[i]]]<<endl;
}
ll y = ask(w);
if(x == y) r = m;
else l = m;
}
return tour[r - 1];
};
s = calc(rt);
t = calc(s);
answer(s, t);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9816 KB |
Output is correct |
2 |
Correct |
3 ms |
9816 KB |
Output is correct |
3 |
Correct |
4 ms |
9848 KB |
Output is correct |
4 |
Correct |
3 ms |
10072 KB |
Output is correct |
5 |
Correct |
3 ms |
9816 KB |
Output is correct |
6 |
Correct |
4 ms |
9816 KB |
Output is correct |
7 |
Correct |
2 ms |
9852 KB |
Output is correct |
8 |
Correct |
3 ms |
9816 KB |
Output is correct |
9 |
Correct |
2 ms |
9816 KB |
Output is correct |
10 |
Correct |
3 ms |
9708 KB |
Output is correct |
11 |
Correct |
2 ms |
9816 KB |
Output is correct |
12 |
Correct |
3 ms |
9816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
9816 KB |
Output is correct |
2 |
Correct |
10 ms |
11352 KB |
Output is correct |
3 |
Correct |
106 ms |
24020 KB |
Output is correct |
4 |
Correct |
115 ms |
24016 KB |
Output is correct |
5 |
Correct |
128 ms |
24016 KB |
Output is correct |
6 |
Correct |
111 ms |
23988 KB |
Output is correct |
7 |
Correct |
98 ms |
24040 KB |
Output is correct |
8 |
Correct |
108 ms |
24276 KB |
Output is correct |
9 |
Correct |
99 ms |
24220 KB |
Output is correct |
10 |
Correct |
102 ms |
24496 KB |
Output is correct |
11 |
Correct |
117 ms |
24400 KB |
Output is correct |
12 |
Correct |
122 ms |
24712 KB |
Output is correct |
13 |
Correct |
99 ms |
24372 KB |
Output is correct |
14 |
Correct |
132 ms |
24412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
11608 KB |
Output is correct |
2 |
Correct |
15 ms |
13320 KB |
Output is correct |
3 |
Correct |
34 ms |
14912 KB |
Output is correct |
4 |
Correct |
86 ms |
24720 KB |
Output is correct |
5 |
Correct |
76 ms |
24592 KB |
Output is correct |
6 |
Correct |
82 ms |
25016 KB |
Output is correct |
7 |
Correct |
95 ms |
25644 KB |
Output is correct |
8 |
Correct |
87 ms |
24904 KB |
Output is correct |
9 |
Correct |
81 ms |
25016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
9816 KB |
Output is correct |
2 |
Correct |
12 ms |
11612 KB |
Output is correct |
3 |
Correct |
69 ms |
21380 KB |
Output is correct |
4 |
Correct |
96 ms |
24100 KB |
Output is correct |
5 |
Correct |
109 ms |
24000 KB |
Output is correct |
6 |
Correct |
116 ms |
24164 KB |
Output is correct |
7 |
Correct |
109 ms |
24124 KB |
Output is correct |
8 |
Correct |
95 ms |
24160 KB |
Output is correct |
9 |
Correct |
116 ms |
24016 KB |
Output is correct |
10 |
Correct |
109 ms |
24120 KB |
Output is correct |
11 |
Correct |
124 ms |
24412 KB |
Output is correct |
12 |
Correct |
121 ms |
24616 KB |
Output is correct |
13 |
Correct |
122 ms |
24404 KB |
Output is correct |
14 |
Correct |
104 ms |
24524 KB |
Output is correct |
15 |
Correct |
114 ms |
24144 KB |
Output is correct |
16 |
Correct |
113 ms |
24180 KB |
Output is correct |
17 |
Correct |
142 ms |
24404 KB |
Output is correct |
18 |
Correct |
117 ms |
24392 KB |
Output is correct |
19 |
Correct |
100 ms |
24268 KB |
Output is correct |
20 |
Correct |
114 ms |
24504 KB |
Output is correct |
21 |
Correct |
100 ms |
24676 KB |
Output is correct |
22 |
Correct |
94 ms |
24900 KB |
Output is correct |
23 |
Correct |
98 ms |
24536 KB |
Output is correct |
24 |
Correct |
106 ms |
24764 KB |
Output is correct |
25 |
Correct |
121 ms |
25120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
11828 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
11352 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |