Submission #824261

# Submission time Handle Problem Language Result Execution time Memory
824261 2023-08-13T22:16:48 Z trangtranha28 Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <climits>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define int long long
using namespace std;

const int MAXN = 1e5 + 2;

int n, m;
int dis[MAXN] = {0}, dis2[MAXN] = {0};
bool check[MAXN] = {false};

vector <int> exits;
vector <pair <int, int> > adj[MAXN];
 
int Dijkstra() {
	// reset:
    memset(dis, 63, sizeof(dis));
	memset(dis2, 63, sizeof(dis2));
	
	// main:
	priority_queue <pair <int, int>, vector <pair <int, int> >, greater <pair <int, int> > > pq;
	
    for(int i = 0; i < (int)(exits.size()); i++) {
    	dis[exits[i]] = 0;
		dis2[exits[i]] = 0;
		pq.push(make_pair(0, exits[i]));
	}
	
    while(pq.empty() == false) {
    	pair <int, int> p = pq.top();
    	pq.pop();
    	
        int u = p.second;
		
        if(check[u] == false) {
        	continue;
		} else {
			check[u] = true;
		}
		
        for(int i = 0; i < (int)(adj[u].size()); i++) {
            int v = adj[u][i].first, w = adj[u][i].second;
            if(dis[v] > dis2[u] + w) {
                dis2[v] = dis[v];
				dis[v] = dis2[u] + w;
                pq.push(make_pair(dis2[v], v));
            } else if(dis2[v]>dis2[u]+w) {
            	dis2[v] = dis2[u] + w;
				pq.push(make_pair(dis2[v], v));
			}
        }
    }
    return dis2[0];
}
 
int plan(int N, int M, int R[][2], int L[], int k, int p[]) {
    n = N, m = M;
    for(int i = 0; i < m; i++) {
        int a = R[i][0], b = R[i][1], c = L[i];
        adj[a].push_back(make_pair(b, c));
		adj[b].push_back(make_pair(a, c));
    }
    for(int i = 0; i < k; i++) {
    	exits.push_back(p[i]);
	}
    return Dijkstra();
}

Compilation message

/usr/bin/ld: /tmp/ccXK56fP.o: in function `main':
grader.cpp:(.text.startup+0x36): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status