#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 - 1;
}
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);
}
};
vll path;
auto calc = [&](ll n){
ll l = 0, r = n;
while(l + 1 < r){
ll m = (l + r) / 2;
if(r - l > 60000) m = 60000;
w.assign(M, 1);
for(auto i : path) w[i] =0;
//~ 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];
};
bfs(rt);
s = calc(n);
{
ll x = s;
while(x != rt){
path.pb(pr[x]);
x = p[x];
}
}
t = calc(s);
answer(s, t);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9816 KB |
Output is correct |
2 |
Correct |
2 ms |
9816 KB |
Output is correct |
3 |
Correct |
2 ms |
9816 KB |
Output is correct |
4 |
Correct |
2 ms |
9816 KB |
Output is correct |
5 |
Correct |
2 ms |
9816 KB |
Output is correct |
6 |
Correct |
2 ms |
9816 KB |
Output is correct |
7 |
Correct |
2 ms |
9816 KB |
Output is correct |
8 |
Correct |
2 ms |
9816 KB |
Output is correct |
9 |
Correct |
2 ms |
9816 KB |
Output is correct |
10 |
Correct |
2 ms |
9816 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 |
3 ms |
9816 KB |
Output is correct |
2 |
Correct |
9 ms |
11352 KB |
Output is correct |
3 |
Correct |
88 ms |
24256 KB |
Output is correct |
4 |
Correct |
82 ms |
24032 KB |
Output is correct |
5 |
Correct |
82 ms |
24024 KB |
Output is correct |
6 |
Correct |
81 ms |
23996 KB |
Output is correct |
7 |
Correct |
85 ms |
24236 KB |
Output is correct |
8 |
Correct |
89 ms |
24280 KB |
Output is correct |
9 |
Correct |
73 ms |
24244 KB |
Output is correct |
10 |
Correct |
81 ms |
24020 KB |
Output is correct |
11 |
Correct |
81 ms |
24236 KB |
Output is correct |
12 |
Correct |
90 ms |
24640 KB |
Output is correct |
13 |
Correct |
85 ms |
24492 KB |
Output is correct |
14 |
Correct |
102 ms |
24412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
11608 KB |
Output is correct |
2 |
Correct |
16 ms |
13256 KB |
Output is correct |
3 |
Correct |
23 ms |
14876 KB |
Output is correct |
4 |
Correct |
64 ms |
24540 KB |
Output is correct |
5 |
Correct |
65 ms |
24760 KB |
Output is correct |
6 |
Correct |
68 ms |
25312 KB |
Output is correct |
7 |
Correct |
68 ms |
25584 KB |
Output is correct |
8 |
Correct |
59 ms |
24944 KB |
Output is correct |
9 |
Correct |
72 ms |
25060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9816 KB |
Output is correct |
2 |
Correct |
10 ms |
11480 KB |
Output is correct |
3 |
Correct |
58 ms |
21244 KB |
Output is correct |
4 |
Correct |
76 ms |
24240 KB |
Output is correct |
5 |
Correct |
93 ms |
24124 KB |
Output is correct |
6 |
Correct |
71 ms |
24120 KB |
Output is correct |
7 |
Correct |
70 ms |
24128 KB |
Output is correct |
8 |
Correct |
81 ms |
24072 KB |
Output is correct |
9 |
Correct |
88 ms |
24148 KB |
Output is correct |
10 |
Correct |
87 ms |
24160 KB |
Output is correct |
11 |
Correct |
95 ms |
24488 KB |
Output is correct |
12 |
Correct |
113 ms |
24324 KB |
Output is correct |
13 |
Correct |
94 ms |
24532 KB |
Output is correct |
14 |
Correct |
94 ms |
24524 KB |
Output is correct |
15 |
Correct |
83 ms |
24232 KB |
Output is correct |
16 |
Correct |
82 ms |
24160 KB |
Output is correct |
17 |
Incorrect |
104 ms |
24320 KB |
Output is incorrect: {s, t} is wrong. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
11352 KB |
Output is correct |
2 |
Correct |
13 ms |
11696 KB |
Output is correct |
3 |
Correct |
99 ms |
25516 KB |
Output is correct |
4 |
Correct |
97 ms |
26320 KB |
Output is correct |
5 |
Correct |
109 ms |
28092 KB |
Output is correct |
6 |
Correct |
116 ms |
28164 KB |
Output is correct |
7 |
Correct |
137 ms |
28132 KB |
Output is correct |
8 |
Correct |
102 ms |
28212 KB |
Output is correct |
9 |
Correct |
114 ms |
21948 KB |
Output is correct |
10 |
Correct |
95 ms |
22808 KB |
Output is correct |
11 |
Correct |
109 ms |
24244 KB |
Output is correct |
12 |
Correct |
112 ms |
26760 KB |
Output is correct |
13 |
Correct |
112 ms |
27472 KB |
Output is correct |
14 |
Correct |
116 ms |
28356 KB |
Output is correct |
15 |
Correct |
109 ms |
28088 KB |
Output is correct |
16 |
Correct |
92 ms |
24288 KB |
Output is correct |
17 |
Correct |
83 ms |
24516 KB |
Output is correct |
18 |
Correct |
95 ms |
24636 KB |
Output is correct |
19 |
Correct |
77 ms |
24380 KB |
Output is correct |
20 |
Correct |
89 ms |
24556 KB |
Output is correct |
21 |
Correct |
103 ms |
28044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
11352 KB |
Output is correct |
2 |
Correct |
11 ms |
11608 KB |
Output is correct |
3 |
Partially correct |
92 ms |
25164 KB |
Output is partially correct |
4 |
Partially correct |
95 ms |
25848 KB |
Output is partially correct |
5 |
Correct |
106 ms |
26420 KB |
Output is correct |
6 |
Correct |
112 ms |
28076 KB |
Output is correct |
7 |
Correct |
84 ms |
25264 KB |
Output is correct |
8 |
Partially correct |
88 ms |
26516 KB |
Output is partially correct |
9 |
Correct |
92 ms |
26344 KB |
Output is correct |
10 |
Correct |
109 ms |
28176 KB |
Output is correct |
11 |
Correct |
116 ms |
28152 KB |
Output is correct |
12 |
Correct |
109 ms |
28160 KB |
Output is correct |
13 |
Correct |
104 ms |
24628 KB |
Output is correct |
14 |
Correct |
109 ms |
22680 KB |
Output is correct |
15 |
Correct |
95 ms |
24244 KB |
Output is correct |
16 |
Correct |
106 ms |
23000 KB |
Output is correct |
17 |
Correct |
99 ms |
24208 KB |
Output is correct |
18 |
Correct |
97 ms |
22696 KB |
Output is correct |
19 |
Partially correct |
112 ms |
26920 KB |
Output is partially correct |
20 |
Correct |
102 ms |
27524 KB |
Output is correct |
21 |
Partially correct |
125 ms |
28272 KB |
Output is partially correct |
22 |
Partially correct |
113 ms |
28172 KB |
Output is partially correct |
23 |
Correct |
121 ms |
28520 KB |
Output is correct |
24 |
Partially correct |
122 ms |
28116 KB |
Output is partially correct |
25 |
Partially correct |
119 ms |
28316 KB |
Output is partially correct |
26 |
Correct |
109 ms |
28116 KB |
Output is correct |
27 |
Correct |
73 ms |
24444 KB |
Output is correct |
28 |
Correct |
80 ms |
24484 KB |
Output is correct |
29 |
Partially correct |
81 ms |
24868 KB |
Output is partially correct |
30 |
Correct |
78 ms |
24420 KB |
Output is correct |
31 |
Correct |
78 ms |
24484 KB |
Output is correct |
32 |
Partially correct |
77 ms |
24412 KB |
Output is partially correct |
33 |
Correct |
80 ms |
25052 KB |
Output is correct |
34 |
Correct |
73 ms |
24976 KB |
Output is correct |
35 |
Correct |
75 ms |
24644 KB |
Output is correct |
36 |
Correct |
78 ms |
24424 KB |
Output is correct |
37 |
Partially correct |
91 ms |
25024 KB |
Output is partially correct |
38 |
Partially correct |
101 ms |
24648 KB |
Output is partially correct |
39 |
Partially correct |
111 ms |
27928 KB |
Output is partially correct |
40 |
Partially correct |
128 ms |
27892 KB |
Output is partially correct |
41 |
Incorrect |
117 ms |
28072 KB |
Output is incorrect: {s, t} is wrong. |
42 |
Halted |
0 ms |
0 KB |
- |