Submission #750798

# Submission time Handle Problem Language Result Execution time Memory
750798 2023-05-30T10:12:10 Z rxlfd314 Cyberland (APIO23_cyberland) C++17
40 / 100
210 ms 20812 KB
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;

double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
	vector<pair<int, double>> adj[N];
	for (int i = 0; i < M; i++) {
		adj[x[i]].push_back({y[i], (double)c[i]});
		adj[y[i]].push_back({x[i], (double)c[i]});
	}
	
	bool useful[N] = {};
	queue<int> qu;
	qu.push(0);
	useful[0] = true;
	while (qu.size()) {
		int f = qu.front();
		qu.pop();
		if (f == H) continue;
		for (auto [nf, _] : adj[f]) {
			if (!useful[nf]) {
				useful[nf] = true;
				qu.push(nf);
			}
		}
	}
	
	vector<vector<double>> dst(min(K, 80)+1, vector<double>(N, 1e14));
	double ans = 1e14;
	for (int ii = 0; ii <= min(K, 80); ii++) {
		priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> pq;
		for (int i = 0; i < N; i++) {
			if (!useful[i]) continue;
			if (arr[i] == 2 && ii) {
				for (auto [j, v] : adj[i]) {
					if (!useful[j] || j == H) continue;
					dst[ii][i] = min(dst[ii][i], (dst[ii-1][j] + v) / 2.0);
				}
				pq.push({dst[ii][i], i});
			} else if (!arr[i]) {
				dst[ii][i] = 0;
				pq.push({0, i});
			}
		}
		if (!ii) {
			dst[0][0] = 0;
			pq.push({0, 0});
		}
		
		while (pq.size()) {
			auto [d, f] = pq.top();
			pq.pop();
			if (d > dst[ii][f] || f == H) continue;
			for (auto [nf, v] : adj[f]) {
				if (d + v < dst[ii][nf] && useful[nf]) {
					dst[ii][nf] = d + v;
					pq.push({d+v, nf});
				}
			}
		}
		
		ans = min(ans, dst[ii][H]);
	}
	
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 468 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 740 KB Correct.
2 Correct 31 ms 748 KB Correct.
3 Correct 32 ms 768 KB Correct.
4 Correct 32 ms 688 KB Correct.
5 Correct 32 ms 712 KB Correct.
6 Correct 27 ms 3800 KB Correct.
7 Correct 36 ms 3736 KB Correct.
8 Correct 17 ms 7380 KB Correct.
9 Correct 33 ms 500 KB Correct.
10 Correct 29 ms 492 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 157 ms 664 KB Correct.
2 Correct 144 ms 684 KB Correct.
3 Correct 138 ms 736 KB Correct.
4 Correct 95 ms 584 KB Correct.
5 Correct 92 ms 476 KB Correct.
6 Correct 40 ms 3340 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 101 ms 20812 KB Correct.
2 Correct 96 ms 660 KB Correct.
3 Correct 86 ms 920 KB Correct.
4 Correct 93 ms 720 KB Correct.
5 Correct 66 ms 472 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 708 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 684 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 668 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 210 ms 1108 KB Wrong Answer.
2 Halted 0 ms 0 KB -