Submission #72585

# Submission time Handle Problem Language Result Execution time Memory
72585 2018-08-26T10:24:37 Z Bruteforceman Crocodile's Underground City (IOI11_crocodile) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e15;

struct data {
	int node;
	long long dist;
	data (int node, long long dist) {
		this -> node = node;
		this -> dist = dist;
	}
	data ( ) {}
	bool operator < (data x) const {
		return dist > x.dist;
	}
};

vector <int> g[100010];
vector <int> c[100010];
long long d[100010][2];
bool vis[100010];

int main(int argc, char const *argv[])
{
	// freopen("in.txt", "r", stdin);
	
	int n, m, k;
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 1; i <= m; i++) {
		int p, q, r;
		scanf("%d %d %d", &p, &q, &r);
		g[p].push_back(q);
		g[q].push_back(p);
		c[p].push_back(r);
		c[q].push_back(r);
	}
	for(int i = 0; i < n; i++) {
		d[i][0] = d[i][1] = inf;
	}

	priority_queue <data> Q;
	for(int i = 0; i < k; i++) {
		int x;
		scanf("%d", &x);
		d[x][1] = d[x][0] = 0;
		Q.push(data(x, 0));
	}
	while(not Q.empty()) {
		data x = Q.top();
		Q.pop();
		int p = x.node;
		long long dist = x.dist;
		if(vis[p] == true) continue;

		vis[p] = true;
		for(unsigned i = 0; i < g[p].size(); i++) {
			long long cost = c[p][i] + dist;
			int q = g[p][i];

			if(d[q][0] >= cost) {
				d[q][1] = d[q][0];
				d[q][0] = cost;
				Q.push( data(q, d[q][1]) );
			} else if (d[q][1] > cost) {
				d[q][1] = cost;
				Q.push( data(q, cost) );
			}
		}
	}
	printf("%lld\n", d[0][1]);
	return 0;
}

Compilation message

crocodile.cpp: In function 'int main(int, const char**)':
crocodile.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &m, &k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &p, &q, &r);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
/tmp/ccAp2vTE.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccmeb8Z2.o:crocodile.cpp:(.text.startup+0x0): first defined here
/tmp/ccAp2vTE.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