Submission #16393

# Submission time Handle Problem Language Result Execution time Memory
16393 2015-08-22T08:59:34 Z comet Crocodile's Underground City (IOI11_crocodile) C++
Compilation error
0 ms 0 KB
#include "crocodile.h"
#include<algorithm>
#include<vector>
#include<queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pp;
typedef vector<pp> vec;
vector<vec> path;
int d[100000][2];
bool visit[100000][2];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
	path.assign(N,vec());
	memset(d,0x3f,sizeof(d));
	for(int i=0;i<M;i++){
		path[R[i][0]].pb(pp(R[i][1],L[i]));
		path[R[i][1]].pb(pp(R[i][0],L[i]));
	}
	int INF=d[0][0];
	queue<pp> Q;
	for(int i=0;i<K;i++){
		Q.push(pp(0,P[i]));
		d[P[i]][0]=0;
	}
	int v,c;
	while(!Q.empty()){
		v=Q.top().second;
		c=-Q.top().first;
		Q.pop();
		for(int i=0;i<path[v].size();i++){
			int u=path[v][i].first;
			int w=path[v][i].second;
			if(d[u][0]>=c+w){
				swap(d[u][0],d[u][1]);
				d[u][0]=c+w;
				if(d[u][1]<INF)Q.push(pp(-d[u][1],u));
			}
			else if(d[u][1]>c+w){
				d[u][1]=c+w;
				Q.push(pp(-d[u][1],u));
			}
		}
	}
	return d[0][1];
}

Compilation message

crocodile.cpp: In function ‘int travel_plan(int, int, int (*)[2], int*, int, int*)’:
crocodile.cpp:14:25: error: ‘memset’ was not declared in this scope
  memset(d,0x3f,sizeof(d));
                         ^
crocodile.cpp:27:7: error: ‘class std::queue<std::pair<int, int> >’ has no member named ‘top’
   v=Q.top().second;
       ^
crocodile.cpp:28:8: error: ‘class std::queue<std::pair<int, int> >’ has no member named ‘top’
   c=-Q.top().first;
        ^
crocodile.cpp:30:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<path[v].size();i++){
                ^