#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[90000];
int dist1[90000], dist2[90000];
bool chk[90000];
void find_pair(int N, vector<int> U, vector<int> V, int A, int B)
{
int M=U.size(), S, T, s, e, E;
vector<int> W(M,0), C1, C2;
queue<int> Q;
long long D=ask(W);
for(int i=0;i<M;i++) {
adj[U[i]].push_back(V[i]);
adj[V[i]].push_back(U[i]);
}
s=0; e=N-1;
while(s<=e) {
int m=(s+e)>>1;
for(int i=0;i<N;i++) W[i]=i<=m;
if(ask(W)!=D) e=m-1;
else s=m+1;
}
E=s;
memset(dist1,0x7f,sizeof(dist1));
memset(dist2,0x7f,sizeof(dist2));
dist1[U[E]]=0; Q.push(U[E]);
while(!Q.empty()) {
int c=Q.front();
Q.pop();
for(auto n: adj[c]) if(dist1[n]>dist1[c]+1) {
dist1[n]=dist1[c]+1;
Q.push(n);
}
}
dist2[V[E]]=0; Q.push(V[E]);
while(!Q.empty()) {
int c=Q.front();
Q.pop();
for(auto n: adj[c]) if(dist2[n]>dist2[c]+1) {
dist2[n]=dist2[c]+1;
Q.push(n);
}
}
s=0; e=D/A-1;
while(s<=e) {
int m=(s+e)>>1;
for(int i=0;i<M;i++) W[i]=(dist1[U[i]]<dist2[U[i]] && dist1[U[i]]>=m)^(dist1[V[i]]<dist2[V[i]] && dist1[V[i]]>=m);
if(ask(W)!=D) s=m+1;
else e=m-1;
}
assert(0<=e && e<D/A);
for(int i=0;i<N;i++) {
if(dist1[i]<dist2[i] && dist1[i]==e) C1.push_back(i);
if(dist1[i]>dist2[i] && dist2[i]==D/A-s) C2.push_back(i);
chk[i]=false;
}
s=0; e=C1.size()-1;
while(s<=e) {
int m=(s+e)>>1;
for(int i=0;i<N;i++) chk[i]=false;
for(int i=0;i<=m;i++) chk[C1[i]]=true;
for(int i=0;i<M;i++) W[i]=chk[U[i]] || chk[V[i]];
if(ask(W)!=D) e=m-1;
else s=m+1;
}
S=C1[s];
s=0; e=C2.size()-1;
while(s<=e) {
int m=(s+e)>>1;
for(int i=0;i<N;i++) chk[i]=false;
for(int i=0;i<=m;i++) chk[C2[i]]=true;
for(int i=0;i<M;i++) W[i]=chk[U[i]] || chk[V[i]];
if(ask(W)!=D) e=m-1;
else s=m+1;
}
T=C2[s];
answer(S,T);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
3064 KB |
Output is correct |
2 |
Correct |
4 ms |
3064 KB |
Output is correct |
3 |
Runtime error |
10 ms |
6360 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
3192 KB |
Output is correct |
2 |
Correct |
20 ms |
3660 KB |
Output is correct |
3 |
Correct |
203 ms |
8044 KB |
Output is correct |
4 |
Correct |
196 ms |
8036 KB |
Output is correct |
5 |
Correct |
208 ms |
8160 KB |
Output is correct |
6 |
Correct |
187 ms |
7968 KB |
Output is correct |
7 |
Correct |
203 ms |
8004 KB |
Output is correct |
8 |
Correct |
205 ms |
8080 KB |
Output is correct |
9 |
Correct |
201 ms |
8012 KB |
Output is correct |
10 |
Correct |
205 ms |
8036 KB |
Output is correct |
11 |
Correct |
200 ms |
7784 KB |
Output is correct |
12 |
Correct |
228 ms |
7740 KB |
Output is correct |
13 |
Correct |
201 ms |
7740 KB |
Output is correct |
14 |
Correct |
214 ms |
7936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
3704 KB |
Output is correct |
2 |
Correct |
40 ms |
4268 KB |
Output is correct |
3 |
Correct |
59 ms |
4672 KB |
Output is correct |
4 |
Correct |
158 ms |
7804 KB |
Output is correct |
5 |
Correct |
152 ms |
7796 KB |
Output is correct |
6 |
Correct |
160 ms |
7816 KB |
Output is correct |
7 |
Correct |
157 ms |
7808 KB |
Output is correct |
8 |
Correct |
165 ms |
7744 KB |
Output is correct |
9 |
Correct |
174 ms |
7928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
3192 KB |
Output is correct |
2 |
Correct |
27 ms |
3576 KB |
Output is correct |
3 |
Correct |
145 ms |
6832 KB |
Output is correct |
4 |
Correct |
207 ms |
8052 KB |
Output is correct |
5 |
Correct |
199 ms |
7944 KB |
Output is correct |
6 |
Correct |
185 ms |
8028 KB |
Output is correct |
7 |
Correct |
191 ms |
7996 KB |
Output is correct |
8 |
Correct |
192 ms |
7892 KB |
Output is correct |
9 |
Correct |
203 ms |
8036 KB |
Output is correct |
10 |
Correct |
208 ms |
8132 KB |
Output is correct |
11 |
Correct |
225 ms |
7744 KB |
Output is correct |
12 |
Correct |
209 ms |
7736 KB |
Output is correct |
13 |
Correct |
212 ms |
7732 KB |
Output is correct |
14 |
Correct |
226 ms |
7816 KB |
Output is correct |
15 |
Correct |
182 ms |
8028 KB |
Output is correct |
16 |
Correct |
182 ms |
7880 KB |
Output is correct |
17 |
Correct |
227 ms |
7732 KB |
Output is correct |
18 |
Correct |
205 ms |
7824 KB |
Output is correct |
19 |
Correct |
181 ms |
7944 KB |
Output is correct |
20 |
Correct |
198 ms |
7728 KB |
Output is correct |
21 |
Correct |
183 ms |
9220 KB |
Output is correct |
22 |
Correct |
199 ms |
9340 KB |
Output is correct |
23 |
Correct |
211 ms |
9004 KB |
Output is correct |
24 |
Correct |
219 ms |
8860 KB |
Output is correct |
25 |
Correct |
226 ms |
8076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
3704 KB |
Output is correct |
2 |
Correct |
28 ms |
3704 KB |
Output is correct |
3 |
Correct |
227 ms |
8264 KB |
Output is correct |
4 |
Correct |
256 ms |
8652 KB |
Output is correct |
5 |
Correct |
275 ms |
9004 KB |
Output is correct |
6 |
Correct |
287 ms |
9044 KB |
Output is correct |
7 |
Correct |
275 ms |
9112 KB |
Output is correct |
8 |
Correct |
296 ms |
9000 KB |
Output is correct |
9 |
Runtime error |
232 ms |
14852 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
3576 KB |
Output is correct |
2 |
Correct |
21 ms |
3704 KB |
Output is correct |
3 |
Correct |
222 ms |
8336 KB |
Output is correct |
4 |
Correct |
230 ms |
8416 KB |
Output is correct |
5 |
Correct |
239 ms |
8664 KB |
Output is correct |
6 |
Correct |
291 ms |
9048 KB |
Output is correct |
7 |
Correct |
226 ms |
8320 KB |
Output is correct |
8 |
Correct |
225 ms |
8368 KB |
Output is correct |
9 |
Correct |
244 ms |
8436 KB |
Output is correct |
10 |
Correct |
275 ms |
8992 KB |
Output is correct |
11 |
Correct |
292 ms |
9064 KB |
Output is correct |
12 |
Correct |
286 ms |
9052 KB |
Output is correct |
13 |
Runtime error |
246 ms |
15580 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Halted |
0 ms |
0 KB |
- |