#include<bits/stdc++.h>
using namespace std;
#define intt long long
#define pb push_back
#define forr(i , x , y) for(int i = x; i <= y;i++)
#define fore(i , n) for(int i = 0 ; i < n;i++)
#define forn(i ,x , y) for(int i = x ; i >= y;i--)
long long ask(const vector<int> &w);
void answer(int s, int t);
const int MAXN = 90001;
intt a , b;
int n;
vector<pair<int ,int>> adj[MAXN];
vector<int> zeros , ones;
intt val;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
map<vector<int> , intt> mp;
intt myask(vector<int> v)
{
if(mp.count(v))
return mp[v];
return mp[v] = ask(v);
}
int go(int root)
{
vector<int> dist(n , n);
vector<bool> vis(n , 0);
dist[root] = 0;
queue<int> q;
q.push(root);
while(!q.empty())
{
int x = q.front();
q.pop();
if(vis[x])
continue;
vis[x] = 1;
for(auto [u , i] : adj[x])
{
if(dist[u] > dist[x] + 1)
{
dist[u] = dist[x] + 1;
q.push(u);
}
}
}
vector<pair<int ,int>> nds;
fore(i , n)
nds.pb({dist[i] , i});
sort(nds.rbegin() , nds.rend());
int l = 0 , r = (int)nds.size();
vector<int> asked = ones;
while(l + 1 < r)
{
int mid = (l + r)/2;
asked = zeros;
forr(j , 0 , mid - 1) {
for(auto i : adj[nds[j].second])asked[i.second] = 1;
}
if(myask(asked) == val)
l = mid;
else
r = mid;
}
return nds[l].second;
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B)
{
n = N;
a = A , b = B;
int m = (int)U.size();
zeros.assign(m , 0);
ones.assign(m , 1);
fore(i , N)adj[i].clear();
val = myask(zeros);
fore(i , m)
{
adj[U[i]].pb({V[i] , i});
adj[V[i]].pb({U[i] , i});
}
int S = go(go(uniform_int_distribution<int>(0 , n - 1)(rng)));
answer(S , go(S));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2388 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Output is correct |
2 |
Correct |
15 ms |
4872 KB |
Output is correct |
3 |
Correct |
149 ms |
28180 KB |
Output is correct |
4 |
Correct |
141 ms |
28320 KB |
Output is correct |
5 |
Correct |
152 ms |
28144 KB |
Output is correct |
6 |
Correct |
124 ms |
28452 KB |
Output is correct |
7 |
Correct |
156 ms |
28256 KB |
Output is correct |
8 |
Correct |
154 ms |
27800 KB |
Output is correct |
9 |
Correct |
146 ms |
27756 KB |
Output is correct |
10 |
Correct |
132 ms |
22556 KB |
Output is correct |
11 |
Correct |
143 ms |
28068 KB |
Output is correct |
12 |
Correct |
152 ms |
27752 KB |
Output is correct |
13 |
Correct |
143 ms |
22668 KB |
Output is correct |
14 |
Correct |
137 ms |
27080 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
4872 KB |
Output is correct |
2 |
Correct |
23 ms |
7392 KB |
Output is correct |
3 |
Correct |
37 ms |
10104 KB |
Output is correct |
4 |
Correct |
107 ms |
27804 KB |
Output is correct |
5 |
Correct |
121 ms |
27424 KB |
Output is correct |
6 |
Correct |
103 ms |
22256 KB |
Output is correct |
7 |
Correct |
112 ms |
26004 KB |
Output is correct |
8 |
Correct |
115 ms |
27460 KB |
Output is correct |
9 |
Correct |
108 ms |
27216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Output is correct |
2 |
Correct |
15 ms |
4964 KB |
Output is correct |
3 |
Correct |
121 ms |
21060 KB |
Output is correct |
4 |
Correct |
184 ms |
28664 KB |
Output is correct |
5 |
Correct |
143 ms |
26408 KB |
Output is correct |
6 |
Correct |
153 ms |
26384 KB |
Output is correct |
7 |
Correct |
145 ms |
24072 KB |
Output is correct |
8 |
Correct |
159 ms |
25936 KB |
Output is correct |
9 |
Correct |
139 ms |
27492 KB |
Output is correct |
10 |
Correct |
171 ms |
27316 KB |
Output is correct |
11 |
Correct |
147 ms |
27652 KB |
Output is correct |
12 |
Correct |
127 ms |
22708 KB |
Output is correct |
13 |
Correct |
147 ms |
27784 KB |
Output is correct |
14 |
Correct |
151 ms |
27900 KB |
Output is correct |
15 |
Correct |
159 ms |
27748 KB |
Output is correct |
16 |
Correct |
141 ms |
24788 KB |
Output is correct |
17 |
Correct |
137 ms |
22632 KB |
Output is correct |
18 |
Correct |
140 ms |
27400 KB |
Output is correct |
19 |
Correct |
149 ms |
26176 KB |
Output is correct |
20 |
Correct |
136 ms |
27184 KB |
Output is correct |
21 |
Correct |
106 ms |
28328 KB |
Output is correct |
22 |
Correct |
108 ms |
23032 KB |
Output is correct |
23 |
Correct |
107 ms |
22684 KB |
Output is correct |
24 |
Correct |
112 ms |
22068 KB |
Output is correct |
25 |
Correct |
122 ms |
22136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
5172 KB |
Output is correct |
2 |
Correct |
16 ms |
5376 KB |
Output is correct |
3 |
Correct |
147 ms |
30812 KB |
Output is correct |
4 |
Correct |
162 ms |
32808 KB |
Output is correct |
5 |
Correct |
201 ms |
38532 KB |
Output is correct |
6 |
Correct |
195 ms |
38404 KB |
Output is correct |
7 |
Correct |
197 ms |
38468 KB |
Output is correct |
8 |
Correct |
163 ms |
38332 KB |
Output is correct |
9 |
Correct |
128 ms |
32384 KB |
Output is correct |
10 |
Correct |
122 ms |
34648 KB |
Output is correct |
11 |
Correct |
120 ms |
28824 KB |
Output is correct |
12 |
Correct |
178 ms |
37452 KB |
Output is correct |
13 |
Correct |
181 ms |
37324 KB |
Output is correct |
14 |
Correct |
180 ms |
38460 KB |
Output is correct |
15 |
Correct |
190 ms |
38016 KB |
Output is correct |
16 |
Correct |
139 ms |
35384 KB |
Output is correct |
17 |
Correct |
108 ms |
28248 KB |
Output is correct |
18 |
Correct |
120 ms |
28968 KB |
Output is correct |
19 |
Correct |
113 ms |
28884 KB |
Output is correct |
20 |
Correct |
121 ms |
29116 KB |
Output is correct |
21 |
Correct |
208 ms |
37316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
5040 KB |
Output is correct |
2 |
Correct |
17 ms |
5256 KB |
Output is correct |
3 |
Correct |
170 ms |
30524 KB |
Output is correct |
4 |
Correct |
163 ms |
31636 KB |
Output is correct |
5 |
Correct |
156 ms |
32768 KB |
Output is correct |
6 |
Partially correct |
180 ms |
38092 KB |
Output is partially correct |
7 |
Correct |
150 ms |
30412 KB |
Output is correct |
8 |
Partially correct |
168 ms |
31752 KB |
Output is partially correct |
9 |
Partially correct |
183 ms |
33660 KB |
Output is partially correct |
10 |
Partially correct |
201 ms |
38268 KB |
Output is partially correct |
11 |
Partially correct |
206 ms |
38484 KB |
Output is partially correct |
12 |
Partially correct |
214 ms |
38476 KB |
Output is partially correct |
13 |
Correct |
137 ms |
35452 KB |
Output is correct |
14 |
Correct |
148 ms |
32404 KB |
Output is correct |
15 |
Correct |
147 ms |
35436 KB |
Output is correct |
16 |
Correct |
132 ms |
34044 KB |
Output is correct |
17 |
Correct |
126 ms |
28276 KB |
Output is correct |
18 |
Correct |
137 ms |
33660 KB |
Output is correct |
19 |
Correct |
173 ms |
37476 KB |
Output is correct |
20 |
Correct |
201 ms |
37904 KB |
Output is correct |
21 |
Correct |
179 ms |
38140 KB |
Output is correct |
22 |
Correct |
199 ms |
38284 KB |
Output is correct |
23 |
Partially correct |
184 ms |
38488 KB |
Output is partially correct |
24 |
Partially correct |
193 ms |
38504 KB |
Output is partially correct |
25 |
Partially correct |
188 ms |
38440 KB |
Output is partially correct |
26 |
Partially correct |
198 ms |
38360 KB |
Output is partially correct |
27 |
Partially correct |
115 ms |
29224 KB |
Output is partially correct |
28 |
Partially correct |
122 ms |
29104 KB |
Output is partially correct |
29 |
Partially correct |
123 ms |
29508 KB |
Output is partially correct |
30 |
Partially correct |
130 ms |
29556 KB |
Output is partially correct |
31 |
Correct |
140 ms |
28584 KB |
Output is correct |
32 |
Correct |
117 ms |
28548 KB |
Output is correct |
33 |
Correct |
133 ms |
28776 KB |
Output is correct |
34 |
Correct |
119 ms |
23088 KB |
Output is correct |
35 |
Partially correct |
131 ms |
29312 KB |
Output is partially correct |
36 |
Partially correct |
120 ms |
29240 KB |
Output is partially correct |
37 |
Partially correct |
117 ms |
29368 KB |
Output is partially correct |
38 |
Partially correct |
114 ms |
29936 KB |
Output is partially correct |
39 |
Partially correct |
228 ms |
37972 KB |
Output is partially correct |
40 |
Correct |
196 ms |
36804 KB |
Output is correct |
41 |
Correct |
160 ms |
37388 KB |
Output is correct |
42 |
Correct |
210 ms |
37800 KB |
Output is correct |