답안 #208610

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
208610 2020-03-11T20:34:55 Z Kenzo_1114 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "crocodile.h"
using namespace std;
const int MAXN = 100010;
const int MAXM = 1000010;
const long long int INF = 1e18 + 7;

int N, M, R[MAXM][2], K, P[MAXN];
long long int L[MAXM]; 

long long int dist[MAXN], dist2[MAXN];
vector<int> graf[MAXN];
vector<long long int> cost[MAXN];

void DIK(int n)
{
	set<pair<pair<long long int, long long int>, int> > s;

	for(int i = 0; i < n; i++)
		s.insert({{dist[i], dist2[i]}, i});

	while(!s.empty())
	{
		int cur = s.begin()->second;
		s.erase(s.begin());

		for(int i = 0; i < graf[cur].size(); i++)
		{
			int adj = graf[cur][i];
			long long int c = cost[cur][i];
			long long int DIST = dist2[cur];

			if(dist[adj] > DIST + c)
			{
				s.erase({{dist[adj], dist2[adj]}, adj});
				dist2[adj] = dist[adj], dist[adj] = DIST + c;
				s.insert({{dist[adj], dist2[adj]}, adj});
			}
			else if(dist2[adj] > DIST + c)
			{
				s.erase({{dist[adj], dist2[adj]}, adj});
				dist2[adj] = DIST + c;
				s.insert({{dist[adj], dist2[adj]}, adj});
			}
		}
	}
}

long long int travel_plan(int n, int m, int r[][2], long long int l[], int k, int p[])
{
	for(int i = 0; i < M; i++)
	{
		int a = r[i][0];
		int b = r[i][1];

		graf[a].push_back(b);
		graf[b].push_back(a);
		cost[a].push_back(l[i]);
		cost[b].push_back(l[i]);
	}

	for(int i = 0; i < k; i++)
		dist[i] = dist2[i] = INF;

	for(int i = 0; i < k; i++)
		dist[p[i]] = dist2[p[i]] = 0;

	DIK(n);

	return dist2[0];
}
/*
int main ()
{
	scanf("%d %d", &N, &M);

	for(int i = 0; i < M; i++)	
		scanf("%d %d", &R[i][0], &R[i][1]);

	for(int i = 0; i < M; i++)	scanf("%lld", &L[i]);

	scanf("%d", &K);

	for(int i = 0; i < K; i++)	scanf("%d", &P[i]);

	printf("%lld\n", travel_plan(N, M, R, L, K, P));
}
*/

Compilation message

crocodile.cpp: In function 'void DIK(int)':
crocodile.cpp:27:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < graf[cur].size(); i++)
                  ~~^~~~~~~~~~~~~~~~~~
/tmp/ccIf5lgc.o: In function `main':
grader.cpp:(.text.startup+0x2d): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status