제출 #678595

#제출 시각아이디문제언어결과실행 시간메모리
678595Dan4LifeSwapping Cities (APIO20_swap)C++17
0 / 100
295 ms16380 KiB
#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define SZ(a) (int)a.size()
using ll = long long;

const int maxn = (int)1e5+10;
const int INF = (ll)1e9;

vector<pair<int,int>> adj[maxn];
ll dis[maxn]; int tot = 0;
int par[maxn];
bool vis[maxn];
int n, m;
bool noCycle = false;
multiset<int> S;
int wei[maxn];

void init(int N, int M, vector<int> u, vector<int> v, vector<int> w) {
	n = N, m = M;
	for(int i = 0; i < M; i++){
		wei[v[i]]=w[i];
		adj[u[i]].pb({v[i],w[i]});
		adj[v[i]].pb({u[i],w[i]}); tot=max(tot,w[i]);
		S.insert(w[i]);
	}
	if(M==N) noCycle=false;
	else noCycle=true;
}
/*
5 4
1 2 3
2 3 4
3 4 5
4 5 6
4
1 2
1 5
2 5
2 4
*/

int getMinimumFuelCapacity(int x, int y) {
	int ans = 0;
	if(n<=3) return -1;
	if(x==0){
		S.erase(S.find(wei[y])); ans = wei[y];
		ans = max({ans, *S.begin(), *next(S.begin())});
		S.insert(wei[y]);
	}
	else{
		S.erase(S.find(wei[x]));
		S.erase(S.find(wei[y]));
		ans = max(wei[x],wei[y]);
		ans = max(ans, *S.begin());
		S.insert(wei[x]); S.insert(wei[y]);
		return ans;
	}
	return -1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...