답안 #234913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
234913 2020-05-26T08:53:08 Z Nodir_Bobiev 악어의 지하 도시 (IOI11_crocodile) C++17
0 / 100
7 ms 2944 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

vector < pair < int, int > > gr[111111];
int cnt[111111], min1[111111], min2[111111];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	for(int i = 0; i < M; i ++ ){
		gr[R[i][0]].push_back({L[i], R[i][1]});
		gr[R[i][1]].push_back({L[i], R[i][0]});
	}
	for( int i = 0; i < N; i ++ ){
		min1[i] = min2[i] = 1e9;
	}
	priority_queue < pair < int, int > > q;
	for( int i = 0; i < K; i ++ ){
		min1[P[i]] = min2[P[i]] = 0;
		q.push({0, P[i]});
	}
	while(!q.empty()){
		auto [dst, v] = q.top(); q.pop();
		for( auto [cost, to]: gr[v] ){
			if( min1[to] >= min2[v]+cost ){
				min2[to] = min1[to];
				min1[to] = min2[v]+cost;
				q.push({-min2[to], to});
			}
			else if( min2[to] > min2[v]+cost ){
				min2[to] = min2[v] + cost;
				q.push({-min2[to], to});
			}
		}
	}
	/*
	for( int i = 0; i < N; i ++ ){
		cout << "min1[" << i <<"]=" << min1[i] << "; min2[" << i << "]="<<min2[i]<<endl;
	}
	*/
	return min2[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:23:15: warning: unused variable 'dst' [-Wunused-variable]
   auto [dst, v] = q.top(); q.pop();
               ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2944 KB Output isn't correct
2 Halted 0 ms 0 KB -