답안 #211476

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
211476 2020-03-20T13:09:14 Z bigg 악어의 지하 도시 (IOI11_crocodile) C++14
0 / 100
2000 ms 5632 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 112345, MAXM = 1123456;

std::vector<int> grafo [MAXN];
std::vector<int> grafop[MAXN];
int marc[MAXN];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	for(int i = 0; i < M; i++){
		int u, v, w;
		u = R[i][0];
		v = R[i][1];
		w = L[i];
		grafo[u].push_back(v);
		grafo[v].push_back(u);
		grafop[u].push_back(w);
		grafop[v].push_back(w);
	}
	priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int > > > q;
	for(int i = 0; i < K; i++){
		q.push(make_pair(0, P[i]));
		marc[P[i]] = 1;
	}
	long long ans;
	while(!q.empty()){
		int v = q.top().second;
		long long c = q.top().first;

		if(!marc[v]){
			marc[v] = 1;
			continue;
		}if(marc[v] == 2) continue;
		if(v == 0){
			ans  = c;
			break;
		}

		marc[v] = 2;
		for(int i = 0; i < grafo[v].size(); i++){
			int viz = grafo[v][i];
			long long p = c + grafop[v][i];
			if(marc[viz] == 2) continue;
			q.push(make_pair(p, viz));

		}

	}


	return (int) ans;
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:42:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < grafo[v].size(); i++){
                  ~~^~~~~~~~~~~~~~~~~
crocodile.cpp:53:15: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
  return (int) ans;
               ^~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2080 ms 5632 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2080 ms 5632 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2080 ms 5632 KB Time limit exceeded
2 Halted 0 ms 0 KB -