Submission #1000974

# Submission time Handle Problem Language Result Execution time Memory
1000974 2024-06-18T12:06:43 Z 0npata Cyberland (APIO23_cyberland) C++17
49 / 100
3000 ms 102484 KB
#include "cyberland.h"
#include<bits/stdc++.h>

using namespace std;

#define vec vector
#define int long long
#define float long double

const float INF = 1e18;

double solve(int32_t N, int32_t M, int32_t K, int32_t H, std::vector<int32_t> x, std::vector<int32_t> y, std::vector<int32_t> c, std::vector<int32_t> t) {
	float ans = INF;


	int n = N;
	int m = M;
	int k = K;

	priority_queue<pair<pair<int, float>, int>, vector<pair<pair<int, float>, int>>, greater<pair<pair<int, float>, int>>> pq;
	vec<vec<bool>> vis(k+2, vec<bool>(n, false));

	vec<vec<pair<int, int>>> g(n);

	for(int i = 0; i<m; i++) {
		g[x[i]].push_back({y[i], c[i]});
		g[y[i]].push_back({x[i], c[i]});
	}

	pq.push({{0, 0}, 0});

	vec<bool> dfs_vis(n, false);
	vec<int> stk{0};
	dfs_vis[0] = true;
	while(stk.size() > 0) {
		int u = stk.back();
		stk.pop_back();

		if(u==H) continue;

		if(t[u] == 0) {
			pq.push({{0, 0}, u});
		}

		for(auto e : g[u]) {
			if(dfs_vis[e.first]) continue;
			stk.push_back(e.first);
			dfs_vis[e.first] = true;
		}
	}

	while(pq.size() > 0) {
		pair<pair<int, float>, int> cur = pq.top();
		pq.pop();

		int ck = cur.first.first;
		float d = cur.first.second;
		int u = cur.second;


		if(ck > k) break;

		if(u == H) {
			ans = min(ans, d);
			continue;
		}
		if(vis[ck][u]) {
			continue;
		}
		vis[ck][u] = true;

		for(auto e : g[u]) {
			int v = e.first;
			float w = e.second;

			if(vis[ck][v]) continue;
			pq.push({{ck, d+w}, v});
			if(t[v] == 2) {
				pq.push({{ck+1, (d+w)/(float)2}, v});
			}
		}
	}

	if(ans == INF) return -1;

	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 34 ms 576 KB Correct.
2 Correct 35 ms 580 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 20 ms 608 KB Correct.
2 Correct 23 ms 616 KB Correct.
3 Correct 23 ms 604 KB Correct.
4 Correct 28 ms 592 KB Correct.
5 Correct 23 ms 612 KB Correct.
6 Correct 28 ms 1460 KB Correct.
7 Correct 30 ms 1696 KB Correct.
8 Correct 11 ms 2792 KB Correct.
9 Correct 25 ms 344 KB Correct.
10 Correct 25 ms 348 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 31 ms 604 KB Correct.
2 Correct 31 ms 628 KB Correct.
3 Correct 27 ms 664 KB Correct.
4 Correct 34 ms 352 KB Correct.
5 Correct 32 ms 508 KB Correct.
6 Correct 6 ms 1824 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 164 ms 7512 KB Correct.
2 Incorrect 177 ms 600 KB Wrong Answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 600 KB Correct.
2 Correct 42 ms 600 KB Correct.
3 Correct 33 ms 652 KB Correct.
4 Correct 31 ms 1828 KB Correct.
5 Correct 21 ms 524 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 24 ms 604 KB Correct.
2 Correct 22 ms 604 KB Correct.
3 Correct 35 ms 9040 KB Correct.
4 Correct 18 ms 1916 KB Correct.
5 Correct 27 ms 360 KB Correct.
6 Correct 25 ms 604 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 329 ms 616 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3084 ms 102484 KB Time limit exceeded
2 Halted 0 ms 0 KB -