#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
int i,j,s,t;
int link[261523],size[234567],c[234567],a[234567],l=12345678,r,tt,k,y,z,n,m,x;
pair<int,pair<int,int>>p[234567];
void init(int N, int M, vector <int> U, vector <int> V, vector <int> W) {
n = N;
m = M;
for (i = 0; i <m; i ++){
p[i].first=W[i];
p[i].second.first=U[i];
p[i].second.second=V[i];
}
sort (p,p+m);
}
int find(int x) {
while (x != link[x])
x = link[x];
return x;
}
bool same(int x, int y) {
return find(x) == find(y);
}
void unite(int x, int y) {
x = find(x);
y = find(y);
if (size[x] < size[y])
swap(x,y);
size[x] += size[y];
if (c[y]==1)
c[x]=1;
link[y] = x;
}
int getMinimumFuelCapacity(int u, int v) {
for (i = 1; i<=n; i ++){
link[i]=i;
size[i]=1;
c[i]=0;
a[i]=0;
}
for (i = 0; i <m; i ++){
x=p[i].second.first;
y=p[i].second.second;
a[x]++;
a[y]++;
if (find(x)==find(y)||a[x]>2||a[y]>2){
c[find(x)]=1;
}
unite(x,y);
if (find(u)==find(v)&&c[find(u)]==1){
return p[i].first;
}
}
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Execution timed out |
2069 ms |
6196 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |