Submission #308960

# Submission time Handle Problem Language Result Execution time Memory
308960 2020-10-02T12:17:34 Z tengiz05 Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
0 ms 0 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9+7;
const int NN = 2e5+5;
vector<pair<int, int>> edges[NN];
multiset<int> dist[NN];
bool com(pair<int, int> &a, pair<int, int> &b){
	return a.first < b.first;
}
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]){
	for(int i=0;i<m;i++){
		edges[R[i][0]].push_back({R[i][1], L[i]});
		edges[R[i][1]].push_back({R[i][0], L[i]});
	}
	priority_queue<pair<int, int>, com> q;
	for(int i=0;i<k;i++){
		dist[P[i]].insert(0);
		dist[P[i]].insert(0);
		
		q.push({0, P[i]});
	}for(int i=0;i<n;i++){
		if(dist[i].empty()){
			dist[i].insert(inf);
			dist[i].insert(inf);
		}
	}
	while(!q.empty()){
		auto pp = q.top();q.pop();
		int d = pp.first;
		int u = pp.second;
		auto dd = dist[u].begin();dd++;
		int D = *dd;
		if(D < d)continue;
		for(auto X : edges[u]){
			int v = X.first;
			int cost = X.second;
			auto ss = dist[v].begin();ss++;
			if(D+cost >= *ss)continue;
			dist[v].erase(dist[v].find(*ss));
			dist[v].insert(D + cost);
			auto s1 = dist[v].begin();s1++;
			if(*s1 != inf){
				q.push({*s1, v});
			}
		}
	}
	auto ans1 = dist[0].begin();ans1++;
	int ans = *ans1;
	return ans;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:16:36: error: type/value mismatch at argument 2 in template parameter list for 'template<class _Tp, class _Sequence, class _Compare> class std::priority_queue'
   16 |  priority_queue<pair<int, int>, com> q;
      |                                    ^
crocodile.cpp:16:36: note:   expected a type, got 'com'
crocodile.cpp:16:36: error: template argument 3 is invalid
crocodile.cpp:21:5: error: request for member 'push' in 'q', which is of non-class type 'int'
   21 |   q.push({0, P[i]});
      |     ^~~~
crocodile.cpp:28:11: error: request for member 'empty' in 'q', which is of non-class type 'int'
   28 |  while(!q.empty()){
      |           ^~~~~
crocodile.cpp:29:15: error: request for member 'top' in 'q', which is of non-class type 'int'
   29 |   auto pp = q.top();q.pop();
      |               ^~~
crocodile.cpp:29:23: error: request for member 'pop' in 'q', which is of non-class type 'int'
   29 |   auto pp = q.top();q.pop();
      |                       ^~~
crocodile.cpp:44:7: error: request for member 'push' in 'q', which is of non-class type 'int'
   44 |     q.push({*s1, v});
      |       ^~~~