Submission #896521

# Submission time Handle Problem Language Result Execution time Memory
896521 2024-01-01T15:27:13 Z LCJLY Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include "crocodile.h"
//
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
//#define int long long
int travel_plan(int n, int m, int r[][2], int w[], int k, int p[]){
	for(int x=0;x<m;x++){
		adj[r[x][0]].push_back({r[x][1],w[x]});
		adj[r[x][1]].push_back({r[x][0],w[x]});
	}
	
	pii dist[n+5];
	//memset(dist,-1,sizeof(dist));
	for(int x=0;x<n;x++){
		dist[x]={1e15,1e15};
	}
	priority_queue<pii,vector<pii>,greater<pii>>pq;
	for(int x=0;x<k;x++){
		dist[p[x]]={0,0};
		pq.push({0,p[x]});
	}
	
	bool visited[n+5];
	memset(visited,0,sizeof(visited));
	while(!pq.empty()){
		pii cur=pq.top();
		pq.pop();
		int x=cur.second;
		int d=cur.first;
		if(dist[x].second!=d) continue;
		visited[x]=true;
		
		for(auto it:adj[x]){
			int nx=it.first;
			int nd=d+it.second;
			if(nd<=dist[nx].first){
				dist[nx].second=dist[nx].first;
				dist[nx].first=nd;
				pq.push({nd,nx});
			}
			else if(nd<dist[nx].second){
				dist[nx].second=nd;
				pq.push({nd,nx});
			}
		}
	}
	
	if(dist[0].second!=-1){
		return dist[0].second;
	}
	else return -1;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:9:3: error: 'adj' was not declared in this scope
    9 |   adj[r[x][0]].push_back({r[x][1],w[x]});
      |   ^~~
crocodile.cpp:34:15: error: 'adj' was not declared in this scope
   34 |   for(auto it:adj[x]){
      |               ^~~