#include "highway.h"
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b;std::vector<int>u,v;std::vector<std::pair<int,int>>g[90001];
int sub12(int src,int ban)
{
vector<int>d(n,1e9),e(n,-1);
queue<pair<int,int>>q; q.emplace(d[src]=0,src);
while(q.size()){auto[c,u]=q.front();q.pop();for(auto[v,i]:g[u])if(ban-i&&d[v]>c+1)q.emplace(d[v]=c+1,v),e[v]=i;}
long long need; {vector<int>qq(m);for(int i=0;i<n;++i)if(~e[i])qq[e[i]]=1;need=ask(qq);}
vector<int>c;
for(int i=0;i<n;++i)if(d[i]<1e9)c.push_back(i);
sort(c.begin(),c.end(),[&d](int i,int v){return d[i]<d[v];});
int z=0,l=0,r=c.size()-1;
while(l<=r){
int y=(l+r)/2;
vector<int>qq(m,0);
for(int i=1;i<=y;++i)if(~e[c[i]])qq[e[c[i]]]=1;
if (ask(qq)==need)z=c[y],r=y-1;
else l=y+1;
}
return z;
}
void sub1234(){
long long need; {vector<int>qq(m,1); need=ask(qq);}
auto dt = need / b;
long long light = dt * a;
int e1,l=0,r=m-1;
while(l<=r) {
int y=(l+r)/2;
vector<int>qq(m);
for(int i=0;i<=y;++i)qq[i]=1;
if(ask(qq)>light)r=y-1,e1=y;
else l=y+1;
}
int p=u[e1],q=v[e1];
int s=sub12(p,e1);
int t=sub12(q,e1);
answer(s,t);
}
void find_pair(int n_, std::vector<int> u_, std::vector<int> v_, int A_, int B_) {
n=n_,u=u_,v=v_,a=A_,b=B_;m=u.size();
for(int i=0;i<m;++i)g[u[i]].push_back({v[i],i}),g[v[i]].push_back({u[i],i});
sub1234();
}
Compilation message
highway.cpp: In function 'void sub1234()':
highway.cpp:44:15: warning: 'e1' may be used uninitialized in this function [-Wmaybe-uninitialized]
44 | int p=u[e1],q=v[e1];
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2392 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 |
2560 KB |
Output is correct |
6 |
Correct |
2 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2552 KB |
Output is correct |
8 |
Correct |
2 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 |
2616 KB |
Output is correct |
2 |
Correct |
11 ms |
3380 KB |
Output is correct |
3 |
Correct |
92 ms |
10120 KB |
Output is correct |
4 |
Correct |
83 ms |
9856 KB |
Output is correct |
5 |
Correct |
82 ms |
9888 KB |
Output is correct |
6 |
Correct |
87 ms |
9808 KB |
Output is correct |
7 |
Correct |
82 ms |
9908 KB |
Output is correct |
8 |
Correct |
91 ms |
9656 KB |
Output is correct |
9 |
Correct |
102 ms |
9936 KB |
Output is correct |
10 |
Correct |
92 ms |
9912 KB |
Output is correct |
11 |
Correct |
85 ms |
9040 KB |
Output is correct |
12 |
Correct |
90 ms |
9264 KB |
Output is correct |
13 |
Correct |
142 ms |
9036 KB |
Output is correct |
14 |
Correct |
93 ms |
9256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
3256 KB |
Output is correct |
2 |
Correct |
20 ms |
4000 KB |
Output is correct |
3 |
Correct |
35 ms |
4584 KB |
Output is correct |
4 |
Correct |
69 ms |
9424 KB |
Output is correct |
5 |
Correct |
68 ms |
9036 KB |
Output is correct |
6 |
Correct |
101 ms |
8980 KB |
Output is correct |
7 |
Correct |
70 ms |
9048 KB |
Output is correct |
8 |
Correct |
102 ms |
9288 KB |
Output is correct |
9 |
Correct |
74 ms |
9192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2612 KB |
Output is correct |
2 |
Correct |
10 ms |
3364 KB |
Output is correct |
3 |
Correct |
79 ms |
7988 KB |
Output is correct |
4 |
Correct |
88 ms |
9652 KB |
Output is correct |
5 |
Correct |
79 ms |
9648 KB |
Output is correct |
6 |
Correct |
83 ms |
9804 KB |
Output is correct |
7 |
Correct |
87 ms |
9664 KB |
Output is correct |
8 |
Correct |
110 ms |
9664 KB |
Output is correct |
9 |
Correct |
95 ms |
10084 KB |
Output is correct |
10 |
Correct |
98 ms |
9880 KB |
Output is correct |
11 |
Correct |
105 ms |
9276 KB |
Output is correct |
12 |
Correct |
128 ms |
9224 KB |
Output is correct |
13 |
Correct |
92 ms |
9200 KB |
Output is correct |
14 |
Correct |
116 ms |
9100 KB |
Output is correct |
15 |
Correct |
73 ms |
9664 KB |
Output is correct |
16 |
Correct |
98 ms |
9664 KB |
Output is correct |
17 |
Correct |
97 ms |
9256 KB |
Output is correct |
18 |
Correct |
130 ms |
9268 KB |
Output is correct |
19 |
Correct |
96 ms |
9692 KB |
Output is correct |
20 |
Correct |
122 ms |
9032 KB |
Output is correct |
21 |
Correct |
72 ms |
10344 KB |
Output is correct |
22 |
Correct |
75 ms |
10224 KB |
Output is correct |
23 |
Correct |
94 ms |
10332 KB |
Output is correct |
24 |
Correct |
104 ms |
9760 KB |
Output is correct |
25 |
Correct |
110 ms |
9156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
3360 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
3396 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |