답안 #392813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
392813 2021-04-21T19:23:57 Z Aryan_Raina 악어의 지하 도시 (IOI11_crocodile) C++14
0 / 100
1 ms 204 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

#define ar array

int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) {
	vector<ar<int,2>> g[n];
	for (int i = 0; i < m; i++) {
		g[R[i][0]].push_back({L[i], R[i][1]});
		g[R[i][1]].push_back({L[i], R[i][0]});
	}
  	priority_queue<ar<int,2>, vector<ar<int,2>>, greater<ar<int,2>>> pq;
  	vector<int> dist(n,  -1);
  	for (int i = 0; i < k; i++) pq.push({0,P[i]});
  	while (!pq.empty()) {
  		int u = pq.top()[1], d = pq.top()[0]; pq.pop();
  		if (dist[u] != -1) continue;
  		dist[u] = d;
  		for (auto v : g[u]) if (dist[v[1]] == -1) {
  			pq.push({d + v[0], v[1]});
  		}
  	}
  	for (int i = 0; i < n; i++) sort(g[i].begin(), g[i].end());
  	int u = 0, pu = -1, res = 0;
  	while (dist[u] != 0) {
  		for (int i = 1; i < g[u].size(); i++) {
  			auto v = g[u][i];
  			if (v[1] == pu) continue;
  			res += v[0];
  			pu = u; u = v[1];
  			break;
  		}
  	}
  	return res;
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (int i = 1; i < g[u].size(); i++) {
      |                     ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -