답안 #462497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
462497 2021-08-10T16:12:39 Z fuad27 악어의 지하 도시 (IOI11_crocodile) C++14
0 / 100
6 ms 460 KB
#include<bits/stdc++.h>
#include "crocodile.h"
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
vector<vector<pair<int, int>>> adj(N);
for(int i = 0; i < M; i++) {
	int u = R[i][0], v = R[i][1];
	adj[u].emplace_back(v, L[i]);
	adj[v].emplace_back(u, L[i]);
}

vector<int> visited(N);
priority_queue<pair<int, int>> q;
for(int i = 0; i < K; i++) {
	visited[P[i]]++;
	q.emplace(0, P[i]);
}

while(!q.empty()) {
	auto [d, v] = q.top();
	q.pop();
	if(visited[v] == 1) {
		visited[v]++;
		if(v == 0) return -d;
		for(auto &[u, w] : adj[v])
			q.emplace(d - w, u);
	}
}
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:20:7: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   20 |  auto [d, v] = q.top();
      |       ^
crocodile.cpp:25:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   25 |   for(auto &[u, w] : adj[v])
      |             ^
crocodile.cpp:5:37: warning: control reaches end of non-void function [-Wreturn-type]
    5 | vector<vector<pair<int, int>>> adj(N);
      |                                     ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -