Submission #121706

# Submission time Handle Problem Language Result Execution time Memory
121706 2019-06-27T00:40:00 Z andremfq Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "crocodile.h"
using namespace std;
const int MAXN=100010,	INF=1000000010;

int n,m,r[MAXN][5],l[MAXN],k,p[MAXN],marc[MAXN],dist[MAXN],resp=INF;
vector<int> grafo[MAXN],peso[MAXN],d[MAXN],v;

void DKT(int s,int n)
{
	set<pair<int,int> > out;
	
	for(int i=0;i<n;i++)
	{
		dist[i]=INF;
		if(i==s)	dist[i]=0;
		out.insert(make_pair(dist[i],i));
	}
	
	while(!out.empty())
	{
		int cur=out.begin()->second;
		out.erase(out.begin());
		for(int i=0;i<grafo[cur].size();i++)
		{
			int viz=grafo[cur][i];
			int p=peso[cur][i];
			if(dist[viz]>dist[cur]+p)
			{
				out.erase(make_pair(dist[viz],viz));
				dist[viz]=dist[cur]+p;
				out.insert(make_pair(dist[viz],viz));
			}
		}
	}
}

int travel_plan(int N,int M,int R[][5],int L[],int K,int P[])
{
	for(int i=0;i<K;i++)
		marc[P[i]]=1;
	
	for(int i=0;i<M;i++)
	{
		int a=R[i][0],	b=R[i][1],	c=L[i];
		grafo[a].push_back(b);	grafo[b].push_back(a);
		peso[a].push_back(c);	peso[b].push_back(c);
		if(marc[a] && marc[b]==0)	d[b].push_back(c),	v.push_back(b);
		if(marc[b] && marc[a]==0)	d[a].push_back(c),	v.push_back(a);
	}
	
	DKT(0,N);
	
	for(int i=0;i<v.size();i++)
	{
		if(d[v[i]].size()<2)	continue;
//		printf("v[i] = %d  dist[%d] = %d\n",i,v[i],dist[v[i]]+d[v[i]][1]);
		resp=min(resp,dist[v[i]]+d[v[i]][1]);
	}
	
	return resp;
}
/*
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("%d",&l[i]);
		
	scanf("%d",&k);
	
	for(int i=0;i<k;i++)
		scanf("%d",&p[i]);
		
	printf("%d\n",travel_plan(n,m,r,l,k,p));
}
*/

Compilation message

crocodile.cpp: In function 'void DKT(int, int)':
crocodile.cpp:24:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<grafo[cur].size();i++)
               ~^~~~~~~~~~~~~~~~~~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[5], int*, int, int*)':
crocodile.cpp:54:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v.size();i++)
              ~^~~~~~~~~
/tmp/ccr4uc2X.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