Submission #984740

# Submission time Handle Problem Language Result Execution time Memory
984740 2024-05-17T04:06:59 Z Jawad_Akbar_JJ Cyberland (APIO23_cyberland) C++17
0 / 100
28 ms 11612 KB
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;
#define ll long long
const ll N = (1<<18) + 1;
ll Mn[N];
vector<pair<ll,ll>> nei[N];

void dijkstra(ll s,ll n){
	for (ll i=1;i<=n;i++)
		if (i != s)
			Mn[i] = 1e17;

	set<pair<ll,ll>> S;
	S.insert({0,s});

	while (S.size() > 0){
		ll u = (*begin(S)).second;
		S.erase(begin(S));
		for (auto [i,w] : nei[u])
			if (Mn[i] > Mn[u] + w){
				S.erase({Mn[i],i});
				Mn[i] = Mn[u] + w;
				S.insert({Mn[i],i}); 
			}
	}
}

double solve(int n, int m, int k, int h, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr){
	for (ll i=0;i<m;i++){
		nei[x[i] + 1].push_back({y[i] + 1,c[i]});
		nei[y[i] + 1].push_back({x[i] + 1,c[i]});
	}
	arr[0] = 0;

	dijkstra(h+1,n);

	for (ll i=1;i<=n;i++)
		nei[i].clear();

	ll ans = 1;

	for (ll i=0;i<n;i++)
		if (arr[i] == 0 and Mn[i+1] < Mn[ans])
			ans = i+1;
	return Mn[ans];
}
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 7000 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 6744 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 6892 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 11612 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 7004 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 7000 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 7004 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 7004 KB Wrong Answer.
2 Halted 0 ms 0 KB -