답안 #749115

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
749115 2023-05-27T11:10:22 Z gun_gan 사이버랜드 (APIO23_cyberland) C++17
0 / 100
41 ms 6352 KB
#include <bits/stdc++.h>
#include "cyberland.h"
using namespace std;
typedef long long ll;

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,int>>> g(N);
	for(int i = 0; i < N; i++) {
		g[x[i]].push_back({y[i], c[i]});
		g[y[i]].push_back({x[i], c[i]});
	}
	priority_queue<pair<ll,ll>> pq;
	vector<ll> d(N, 1e18);
	d[0] = 0;
	pq.push({0, 0});

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

	while(!pq.empty()) {
		auto [x, v] = pq.top(); pq.pop();
		if(d[v] < x) continue;
		for(auto [u, w] : g[v]) {
			if(d[u] > x + w) {
				d[u] = x + w;
				pq.push({d[u], u});
			}
		} 
	}

	double res = d[H];
	if(res == 1e18) res = -1;
	return res;
}	

// int main() {
// 	cin.tie(0); ios_base::sync_with_stdio(0);

// 	cout << fixed << setprecision(1) << solve(3, 1, 30, 2, {1}, {2}, {12}, {1, 2, 1}) << '\n';
// }
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 6352 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 724 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -