Submission #769946

# Submission time Handle Problem Language Result Execution time Memory
769946 2023-06-30T14:31:30 Z gromperen Cyberland (APIO23_cyberland) C++17
15 / 100
27 ms 5716 KB
#include "cyberland.h"

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const double INF = 1e18;

double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
	vector<ll> dist(N, INF);
	vector<vector<pair<int,int>>> adj(N);
	for (int i = 0; i < M; ++i) {
		adj[x[i]].push_back({y[i], c[i]});
		adj[y[i]].push_back({x[i], c[i]});
	}

	priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> pq;
	arr[0] = 0;


	pq.push({0,0});
	//for (int i = 0; i < N; ++i) {
		//if (arr[i] == 0) pq.push({0, i});
	//}


	while(!pq.empty()) {
		int cur = pq.top().second;
		ll d = pq.top().first;
		pq.pop();
		if (dist[cur] < d) continue;
		dist[cur] = d;
		//if (arr[cur] == 0) return d;
		for (auto [nxt, cost] : adj[cur]) {
			if (arr[nxt] == 0 && dist[nxt] > 0) {
				dist[nxt] = 0;
				pq.push({0, nxt});
			}
			if (dist[nxt] > d + cost) {
				dist[nxt] = d + cost;
				pq.push({dist[nxt], nxt});
			}

		}
	}
	if (dist[H] == INF) return -1;
	return (double)dist[H];


}
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 360 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 480 KB Correct.
2 Correct 23 ms 424 KB Correct.
3 Correct 22 ms 408 KB Correct.
4 Correct 23 ms 428 KB Correct.
5 Correct 22 ms 440 KB Correct.
6 Correct 21 ms 1260 KB Correct.
7 Correct 24 ms 1304 KB Correct.
8 Correct 10 ms 2268 KB Correct.
9 Correct 21 ms 340 KB Correct.
10 Correct 21 ms 384 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 428 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 5716 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 480 KB Correct.
2 Correct 22 ms 340 KB Correct.
3 Correct 21 ms 456 KB Correct.
4 Correct 20 ms 1364 KB Correct.
5 Correct 19 ms 376 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 456 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 340 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 452 KB Wrong Answer.
2 Halted 0 ms 0 KB -