Submission #109137

# Submission time Handle Problem Language Result Execution time Memory
109137 2019-05-04T16:32:20 Z pamaj Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
const int maxn = 1e5 + 10;

typedef pair<int, int> pii;

int vis[maxn], dist[maxn];
vector<pii> G[maxn];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	memset(dist, 0x3f3f3f3f3f, sizeof(dist));

	for(int i = 0; i < M; i++)
	{
		int a = R[i][0], b = R[i][1];

		G[a].push_back({L[i], b});
		G[b].push_back({L[i], a});
	}

	priority_queue<pii, vector<pii>, greater<pii>> q;

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

		q.push({0, p[i]});
	}

	while(!q.empty())
	{
		auto a = q.top();
		q.pop();

		if(vis[a.second] == 0)
		{
			vis[a.second]++;
			continue;
		}
		else if(vis[a.second] == 2)
		{
			continue;
		}
		vis[a.second]++;

		for(auto u : G[a.second])
		{
			if(dist[u.second] > dist[a.second] + u.first)
			{
				dist[u.second] = dist[a.second] + u.first;
				q.push({dist[u.second], u.second});
			}
		}
	}

	return dist[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:13:41: warning: overflow in implicit constant conversion [-Woverflow]
  memset(dist, 0x3f3f3f3f3f, sizeof(dist));
                                         ^
crocodile.cpp:25:21: error: 'k' was not declared in this scope
  for(int i = 0; i < k; i++)
                     ^
crocodile.cpp:27:8: error: 'p' was not declared in this scope
   dist[p[i]] = 0;
        ^
crocodile.cpp:29:19: error: no matching function for call to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::push(<brace-enclosed initializer list>)'
   q.push({0, p[i]});
                   ^
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from crocodile.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:595:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>]
       push(const value_type& __x)
       ^~~~
/usr/include/c++/7/bits/stl_queue.h:595:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_queue.h:603:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>]
       push(value_type&& __x)
       ^~~~
/usr/include/c++/7/bits/stl_queue.h:603:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::value_type&& {aka std::pair<int, int>&&}'