답안 #211312

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
211312 2020-03-20T03:38:11 Z socho 악어의 지하 도시 (IOI11_crocodile) C++14
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
#define int long long

#include "crocodile.h"

int n, m;
const int MXN = 100005;
vector<pair<int, int> > adj[MXN];
bool ter[MXN];
int dist[MXN];
int via[MXN];

int best() {
	int dis[MXN];
	for (int i=0; i<n; i++) dis[i] = INT_MAX;
	dis[0] = 0;
	priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >, greater<pair<int, pair<int, int> > > > src;
	src.push(make_pair(0, make_pair(0, -1)));
	while (!src.empty()) {
		int di = src.top().first;
		int no = src.top().second.first;
		// int fr = src.top().second.second;
		src.pop();
		
		if (dis[no] < di) continue;
		dis[no] = di;
		
		for (int i=0; i<adj[no].size(); i++) {
			int ot = adj[no][i].first;
			int od = adj[no][i].second;
			if (ot == via[no]) continue; // cant take optimal
			if (dis[ot] > od + di) {
				dis[ot] = od + di;
				src.push(make_pair(dis[ot], make_pair(ot, no)));
			}
		}
	}
	int be = INT_MAX;
	for (int i=0; i<n; i++) {
		if (ter[i]) be = min(be, dis[i]);
	}
	return be;
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	
	n = N;
	m = M;
	for (int i=0; i<m; i++) {
		adj[R[i][0]].push_back(make_pair(R[i][1], L[i]));
		adj[R[i][1]].push_back(make_pair(R[i][0], L[i]));
	}
	
	
	for (int i=0; i<n; i++) dist[i] = INT_MAX, via[i] = INT_MAX;
	
	priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >, greater<pair<int, pair<int, int> > > > src;
	
	int p = K;
	for (int i=0; i<p; i++) {
		int x = P[i];
		ter[x] = true;
		dist[x] = 0;
		src.push(make_pair(0, make_pair(x, -1)));
	}
	
	while (!src.empty()) {
		
		int di = src.top().first;
		int no = src.top().second.first;
		int fr = src.top().second.second;
		src.pop();
		
		if (dist[no] < di) continue;
		dist[no] = di;
		via[no] = fr;
		
		for (int i=0; i<adj[no].size(); i++) {
			int on = adj[no][i].first;
			int od = adj[no][i].second;
			if (dist[on] > di + od) {
				dist[on] = di + od;
				src.push(make_pair(dist[on], make_pair(on, no)));
			}
		}
		
	}
	
  return N;
}

Compilation message

crocodile.cpp: In function 'long long int best()':
crocodile.cpp:30:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<adj[no].size(); i++) {
                 ~^~~~~~~~~~~~~~~
crocodile.cpp: In function 'long long int travel_plan(long long int, long long int, long long int (*)[2], long long int*, long long int, long long int*)':
crocodile.cpp:81:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<adj[no].size(); i++) {
                 ~^~~~~~~~~~~~~~~
/tmp/ccuapdzh.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