#include<bits/stdc++.h>
#include "highway.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
const int maxn=9e4+5;
int n,m,a,b;
vector<int>u,v;
vector<pair<int,int>>adj[maxn];
vector<int>par(maxn,0),dep(maxn,0),edge(maxn,0),w;
vector<bool>used(maxn);
void dfs(int x,int p){
par[x]=p;
for(auto [y,e]:adj[x]){
if(y!=p){
dep[y]=dep[x]+1;
edge[y]=e;
dfs(y,x);
}
}
}
void find_pair(int N,vector<int>U,vector<int>V,int A, int B){
n=N,u=U,v=V,a=A,b=B;
m=u.size();
w.resize(m);
fill(all(w),0);
for(int i=0;i<m;i++){
adj[u[i]].pb({v[i],i});
adj[v[i]].pb({u[i],i});
}
ll C=ask(w);
dep[0]=0;
dfs(0,-1);
vector<int>ver;
for(int i=1;i<n;i++){
if((ll)dep[i]*(ll)a==C){
ver.pb(i);
}
}
int l=0,r=ver.size()-1;
while(l<r){
int mid=(l+r)/2;
fill(all(w),0);
for(int i=0;i<=mid;i++){
w[edge[ver[i]]]=1;
}
ll cost=ask(w);
if(cost>C){
r=mid;
}
else{
l=mid+1;
}
}
answer(0,ver[l]);
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3416 KB |
Output is correct |
2 |
Correct |
1 ms |
3416 KB |
Output is correct |
3 |
Correct |
1 ms |
3416 KB |
Output is correct |
4 |
Correct |
1 ms |
3416 KB |
Output is correct |
5 |
Correct |
1 ms |
3416 KB |
Output is correct |
6 |
Correct |
2 ms |
3416 KB |
Output is correct |
7 |
Correct |
1 ms |
3424 KB |
Output is correct |
8 |
Correct |
2 ms |
3416 KB |
Output is correct |
9 |
Correct |
2 ms |
3416 KB |
Output is correct |
10 |
Correct |
1 ms |
3420 KB |
Output is correct |
11 |
Correct |
2 ms |
3416 KB |
Output is correct |
12 |
Correct |
2 ms |
3416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3672 KB |
Output is correct |
2 |
Correct |
7 ms |
4184 KB |
Output is correct |
3 |
Correct |
69 ms |
9560 KB |
Output is correct |
4 |
Correct |
67 ms |
9444 KB |
Output is correct |
5 |
Correct |
67 ms |
9552 KB |
Output is correct |
6 |
Correct |
68 ms |
9476 KB |
Output is correct |
7 |
Correct |
73 ms |
9508 KB |
Output is correct |
8 |
Correct |
69 ms |
9800 KB |
Output is correct |
9 |
Correct |
62 ms |
9424 KB |
Output is correct |
10 |
Correct |
72 ms |
9552 KB |
Output is correct |
11 |
Correct |
65 ms |
9700 KB |
Output is correct |
12 |
Correct |
66 ms |
10208 KB |
Output is correct |
13 |
Correct |
67 ms |
9804 KB |
Output is correct |
14 |
Correct |
66 ms |
9552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
4440 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3672 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
260 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
217 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |