답안 #1008333

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1008333 2024-06-26T09:33:24 Z overwatch9 자매 도시 (APIO20_swap) C++17
컴파일 오류
0 ms 0 KB
#include "swap.h"

#include <bits/stdc++.h>
using namespace std;

vector <vector <pair <int, int>>> adj;
int n, m;
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
	// ios_base::sync_with_stdio(false);
	// cin.tie(0);
	// cout.tie(0);
    adj.resize(N+1);
	n = N;
	m = M;
    for (int i = 0; i < M; i++) {
        adj[U[i]].push_back({V[i], W[i]});
		adj[V[i]].push_back({U[i], W[i]});
	}
}
const int maxn = 1e5 + 1;
int dis[maxn];
priority_queue <pair <int, int>> pq;
bool vis[maxn], processed[maxn];
bool skip = true;
int dfs(int s, int p, int st) {
	if (s == st && !skip) {
		return 0;
	}
	skip = false;
	if (vis[s])
		return 1e9;
	vis[s] = true;
	int ans = 1e9;
	for (auto i : adj[s]) {
		if (i.first == p)
			continue;
		ans = min(ans, max(i.second, dfs(i.first, s, st)));
	}
	vis[s] = false;
	return ans;
}
int getMinimumFuelCapacity(int x, int y) {
	fill(processed, processed + n + 1, false);
	pq.push({0, x});
	fill(dis, dis + n + 1, 1e9 + 1);
	dis[x] = 0;
	while (!pq.empty()) {
		int s = pq.top().second;
		pq.pop();
		if (processed[s])
			continue;
		processed[s] = true;
		for (auto i : adj[s]) {
			int d = max(dis[s], i.second);
			if (d < dis[i.first]) {
				dis[i.first] = d;
				pq.push({-d, i.first});
			}
		}
	}
	if (dis[y] == 1e9 + 1)
		return -1;
	skip = true;
	fill(vis, vis + n + 1, false);
	int ans = dfs(x, x, x);
	return max(ans, dis[y]);
}
int main() {
	int N, M;
	cin >> N >> M;
	vector <int> u(M), v(M), w(M);
	for (int i = 0; i < M; i++)
		cin >> u[i] >> v[i] >> w[i];
	init(N, M, u, v, w);
	int q;
	cin >> q;
	while (q--) {
		int x, y;
		cin >> x >> y;
		cout << getMinimumFuelCapacity(x, y) << '\n';
	}
}

Compilation message

/usr/bin/ld: /tmp/ccLDmgHo.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccv1deMq.o:swap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status