제출 #933506

#제출 시각아이디문제언어결과실행 시간메모리
933506XXBabaProBerkay사이버랜드 (APIO23_cyberland)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second
 
using ll = long long;
 
const int INF = 1e9 + 7;
 
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr)
{
	vector<vector<pair<int, ll>>> adj(N);
	for (int i = 0; i < M; i++)
	{
		adj[x[i]].emplace_back(y[i], c[i]);
		adj[y[i]].emplace_back(x[i], c[i]);
	}
 
	queue<int> Q;
	vector<bool> vis(N);
	Q.push(0);
	vis[0] = 1;
	while (!Q.empty())
	{
		int u = Q.front();
		Q.pop();
 
		for (pair<int, int> i : adj[u])
			if (!vis[i.F] && i.F != H)
			{
				vis[i.F] = 1;
				Q.push(i.F);
			}
	}
 
	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> PQ;
	vector<ll> dist(N, 1e18);
 
	for (int i = 1; i < N; i++)
		if (vis[i] && !arr[i])
		{
			dist[i] = 0;
			PQ.emplace(0, i);
		}
 
	dist[0] = 0;
	PQ.emplace(0, 0);
	while (!PQ.empty())
	{
		ll d;
		int u;
		tie(d, u) = PQ.top();
		PQ.pop();
 
		if (d != dist[u])
			continue;
 
		for (pair<int, ll> i : adj[u])
		{
			int v;
			ll w;
			tie(v, w) = i;
			if (dist[v] > dist[u] + w)
				PQ.emplace(dist[v] = dist[u] + w, v);
		}
	}

	for (int i = 1; i < N; i++)
		if (arr[i] == 2 && vis[i])
		{
			ll mn = 1e18;
			for (auto j : adj[i])
				mn = min(mn, j.S);

			if (mn < dist[i])
				for (int j = 0; j < K; j++)
					dist[i] = (dist[i] + mn) / 2;

			PQ.emplace(dist[i], i);
		}
		else if (arr[i] == 0 && vis[i])
			PQ.emplace(dist[i], i);
		else
			dist[i] = 1e18;

	dist[0] = 0;
	PQ.emplace(0, 0);
	while (!PQ.empty())
	{
		ll d;
		int u;
		tie(d, u) = PQ.top();
		PQ.pop();

		if (d != dist[u])
			continue;

		for (pair<int, ll> i : adj[u])
		{
			int v;
			ll w;
			tie(v, w) = i;
			if (dist[v] > dist[u] + w)
				PQ.emplace(dist[v] = dist[u] + w, v);
		}
	}
 
	return (dist[H] == 1e18 ? -1.0 : double(dist[H]));
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int N, M, K, H;
	cin >> N >> M >> K >> H;
	vector<int> arr(N), x(M), y(M), c(M);
	for (int i = 0; i < N; i++)
		cin >> arr[i];

	for (int i = 0; i < M; i++)
		cin >> x[i];

	for (int i = 0; i < M; i++)
		cin >> y[i];

	for (int i = 0; i < M; i++)
		cin >> c[i];

	cout << solve(N, M, K, H, x, y, c, arr) << '\n';
}

컴파일 시 표준 에러 (stderr) 메시지

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