이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
vector<tuple<int,int,int>> edg;
void init(int N,int M,vector<int>U,vector<int>V,vector<int>W) {
for(int i=0;i<M;i++)
edg.push_back({W[i],++U[i],++V[i]});
sort(edg.begin(),edg.end());
}
int par[100100],deg[100100];
bitset<100100>yes;
int abp(int n){
return par[n]?par[n]=abp(par[n]):n;
}
int getMinimumFuelCapacity(int X,int Y) {
yes.reset(); ++X,++Y;
memset(par,0,sizeof par);
memset(deg,0,sizeof deg);
for(auto[w,u,v]:edg){
deg[u]++,deg[v]++;
if(deg[u]>2)
yes[abp(v)]=1;
if(deg[v]>2)
yes[abp(v)]=1;
u=abp(u),v=abp(v);
if(u-v) par[u]=v,
yes[v]=yes[v]|yes[u];
else yes[v]=1;
if(abp(X)==abp(Y)&&yes[abp(X)])
return w;
}
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |