#include "highway.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn=90010;
vector<pair<int,int> > g[maxn];
int uradi(int n,int m,int a,int b,ll bez,int prva,int pocetak,int skoropocetak,vector<int> &u,vector<int> &v){
queue<int> bfs;
bfs.push(pocetak);
vector<bool> posetio(n,0);
posetio[pocetak]=true;
for(auto i:g[pocetak]){
if(i.first!=skoropocetak) posetio[i.first]=true;
}
vector<int> redosled;
vector<int> intime(n,0);
int t=0;
while(!bfs.empty()){
int node=bfs.front();
intime[node]=t++;
bfs.pop();
for(auto [u,ind]:g[node]){
if(posetio[u]) continue;
if(ind<prva) continue;
posetio[u]=true;
bfs.push(u);
redosled.push_back(ind);
}
}
int l=0;
int r=int(redosled.size())-1; // ?
int ret=-1;
while(l<=r){
int mid=l+(r-l)/2;
vector<int> w(m,0);
fill(w.begin(),w.begin()+prva,1);
for(int i=mid;i<int(redosled.size());i++){
w[redosled[i]]=1;
}
if(ask(w)>bez){
ret=mid;
l=mid+1;
}else r=mid-1;
}
if(intime[u[redosled[ret]]]>intime[v[redosled[ret]]]){
return u[redosled[ret]];
}else return v[redosled[ret]];
}
void find_pair(int n,vector<int> u,vector<int> v,int a,int b) {
int m=u.size();
int prva=0;
int l=1,r=m;
ll bez=ask(vector<int>(m,0));
while(l<=r){
int mid=l+(r-l)/2;
vector<int> w(m,0);
fill(w.begin(),w.begin()+mid,1);
if(ask(w)>bez){
prva=mid;
r=mid-1;
}else l=mid+1;
}
prva--;
for(int i=0;i<m;i++){
g[u[i]].push_back({v[i],i});
g[v[i]].push_back({u[i],i});
}
int lik1=uradi(n,m,a,b,bez,prva,u[prva],v[prva],u,v);
int lik2=uradi(n,m,a,b,bez,prva,v[prva],u[prva],u,v);
//cout<<lik1<<" "<<lik2<<"\n";
answer(lik1,lik2);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2552 KB |
Output is correct |
2 |
Correct |
1 ms |
2548 KB |
Output is correct |
3 |
Correct |
1 ms |
2552 KB |
Output is correct |
4 |
Correct |
1 ms |
2552 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2552 KB |
Output is correct |
7 |
Correct |
1 ms |
2552 KB |
Output is correct |
8 |
Correct |
1 ms |
2552 KB |
Output is correct |
9 |
Correct |
1 ms |
2552 KB |
Output is correct |
10 |
Correct |
2 ms |
2556 KB |
Output is correct |
11 |
Correct |
2 ms |
2548 KB |
Output is correct |
12 |
Correct |
1 ms |
2556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2568 KB |
Output is correct |
2 |
Correct |
10 ms |
3300 KB |
Output is correct |
3 |
Correct |
82 ms |
8636 KB |
Output is correct |
4 |
Correct |
98 ms |
8688 KB |
Output is correct |
5 |
Correct |
83 ms |
8788 KB |
Output is correct |
6 |
Correct |
83 ms |
8500 KB |
Output is correct |
7 |
Correct |
88 ms |
8640 KB |
Output is correct |
8 |
Correct |
100 ms |
8556 KB |
Output is correct |
9 |
Correct |
73 ms |
8708 KB |
Output is correct |
10 |
Correct |
90 ms |
8548 KB |
Output is correct |
11 |
Correct |
76 ms |
7624 KB |
Output is correct |
12 |
Correct |
81 ms |
8220 KB |
Output is correct |
13 |
Correct |
93 ms |
8700 KB |
Output is correct |
14 |
Correct |
85 ms |
8212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
3192 KB |
Output is correct |
2 |
Correct |
18 ms |
3780 KB |
Output is correct |
3 |
Correct |
25 ms |
4240 KB |
Output is correct |
4 |
Correct |
103 ms |
8132 KB |
Output is correct |
5 |
Correct |
69 ms |
7980 KB |
Output is correct |
6 |
Correct |
73 ms |
8176 KB |
Output is correct |
7 |
Correct |
59 ms |
7780 KB |
Output is correct |
8 |
Correct |
109 ms |
8244 KB |
Output is correct |
9 |
Correct |
62 ms |
7720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2568 KB |
Output is correct |
2 |
Correct |
8 ms |
3196 KB |
Output is correct |
3 |
Correct |
58 ms |
7248 KB |
Output is correct |
4 |
Correct |
104 ms |
8460 KB |
Output is correct |
5 |
Correct |
92 ms |
8040 KB |
Output is correct |
6 |
Correct |
91 ms |
8212 KB |
Output is correct |
7 |
Correct |
74 ms |
8680 KB |
Output is correct |
8 |
Correct |
102 ms |
8284 KB |
Output is correct |
9 |
Correct |
82 ms |
8944 KB |
Output is correct |
10 |
Correct |
78 ms |
8764 KB |
Output is correct |
11 |
Correct |
90 ms |
8472 KB |
Output is correct |
12 |
Correct |
76 ms |
7996 KB |
Output is correct |
13 |
Correct |
89 ms |
8304 KB |
Output is correct |
14 |
Correct |
96 ms |
8076 KB |
Output is correct |
15 |
Correct |
89 ms |
8320 KB |
Output is correct |
16 |
Correct |
91 ms |
8204 KB |
Output is correct |
17 |
Correct |
82 ms |
7916 KB |
Output is correct |
18 |
Correct |
99 ms |
8240 KB |
Output is correct |
19 |
Correct |
67 ms |
8060 KB |
Output is correct |
20 |
Correct |
76 ms |
7524 KB |
Output is correct |
21 |
Correct |
64 ms |
8676 KB |
Output is correct |
22 |
Correct |
86 ms |
8676 KB |
Output is correct |
23 |
Correct |
86 ms |
8644 KB |
Output is correct |
24 |
Correct |
74 ms |
8824 KB |
Output is correct |
25 |
Correct |
118 ms |
8312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
3356 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
3280 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |