Submission #1268487

#TimeUsernameProblemLanguageResultExecution timeMemory
1268487bajtozaurCrocodile's Underground City (IOI11_crocodile)C++20
Compilation error
0 ms0 KiB
#include "crocodile.h"

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){

	vector<pair<int, int>> G[N+5];
	//<to, cost>
	
	vector<int> block(N+5, -1);
	vector<bool> odw(N+5, 0);

	priority_queue<pair<int, pair<int, int>>> PQ;
	//<-cost>,<from, to>

	for(int i=0; i<M; i++){
		G[R[i][0]].push_back({R[i][1], L[i]});
		G[R[i][1]].push_back({R[i][0], L[i]});
	}
	
	
	/////////
	
	for(int i=0; i<K; i++){
		int e = P[i];
		odw[e] = 1;
		for(int j=0; j<G[e].size(); j++){
			PQ.push({-G[e][j].second, {e, G[e][j].first}});
			//cout << G[e][j].second << ' ' << e << ' ' << G[e][j].first << '\n';
		}
	}
	
	
	while(!PQ.empty()){
		
		int cost = -PQ.top().first;
		int from = PQ.top().second.first;
		int to = PQ.top().second.second;
		
		//cout << "go " << cost << ' ' << from << ' ' << to << '\n';
		
		if(block[to] == -1){
			block[to] = from;
		}else{
			if(to == 0){
				return cost;
			}
			if(!odw[to]){
				for(int i=0; i<G[to].size(); i++){
					pair<int, int> s = G[to][i];
					if(s.first != from && s.first != block[to]){
						PQ.push({-(cost+s.second), {to, s.first}});
						//cout << "add " << cost+s.second << ' ' << to << ' ' << s.first << '\n';
					}
				}
			}
		}
		
		PQ.pop();
	}
	return 0;
}

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:5:16: error: 'pair' was not declared in this scope
    5 |         vector<pair<int, int>> G[N+5];
      |                ^~~~
crocodile.cpp:5:9: error: 'vector' was not declared in this scope
    5 |         vector<pair<int, int>> G[N+5];
      |         ^~~~~~
crocodile.cpp:5:21: error: expected primary-expression before 'int'
    5 |         vector<pair<int, int>> G[N+5];
      |                     ^~~
crocodile.cpp:8:16: error: expected primary-expression before 'int'
    8 |         vector<int> block(N+5, -1);
      |                ^~~
crocodile.cpp:9:16: error: expected primary-expression before 'bool'
    9 |         vector<bool> odw(N+5, 0);
      |                ^~~~
crocodile.cpp:11:9: error: 'priority_queue' was not declared in this scope
   11 |         priority_queue<pair<int, pair<int, int>>> PQ;
      |         ^~~~~~~~~~~~~~
crocodile.cpp:11:29: error: expected primary-expression before 'int'
   11 |         priority_queue<pair<int, pair<int, int>>> PQ;
      |                             ^~~
crocodile.cpp:15:17: error: 'G' was not declared in this scope
   15 |                 G[R[i][0]].push_back({R[i][1], L[i]});
      |                 ^
crocodile.cpp:24:17: error: 'odw' was not declared in this scope
   24 |                 odw[e] = 1;
      |                 ^~~
crocodile.cpp:25:32: error: 'G' was not declared in this scope
   25 |                 for(int j=0; j<G[e].size(); j++){
      |                                ^
crocodile.cpp:26:25: error: 'PQ' was not declared in this scope; did you mean 'P'?
   26 |                         PQ.push({-G[e][j].second, {e, G[e][j].first}});
      |                         ^~
      |                         P
crocodile.cpp:32:16: error: 'PQ' was not declared in this scope; did you mean 'P'?
   32 |         while(!PQ.empty()){
      |                ^~
      |                P
crocodile.cpp:40:20: error: 'block' was not declared in this scope
   40 |                 if(block[to] == -1){
      |                    ^~~~~
crocodile.cpp:46:29: error: 'odw' was not declared in this scope
   46 |                         if(!odw[to]){
      |                             ^~~
crocodile.cpp:47:48: error: 'G' was not declared in this scope
   47 |                                 for(int i=0; i<G[to].size(); i++){
      |                                                ^
crocodile.cpp:48:46: error: expected primary-expression before 'int'
   48 |                                         pair<int, int> s = G[to][i];
      |                                              ^~~
crocodile.cpp:49:44: error: 's' was not declared in this scope
   49 |                                         if(s.first != from && s.first != block[to]){
      |                                            ^