Submission #322390

# Submission time Handle Problem Language Result Execution time Memory
322390 2020-11-14T14:49:05 Z Farrius Crocodile's Underground City (IOI11_crocodile) C++11
Compilation error
0 ms 0 KB
#include "crocodile.h"
#include <bits/stdc++.h>

#define len(x) (int) x.size()
#define f first
#define s second
using namespace std;
using ll = long long;
using ld = long double;

const int INF = 1e9;

int travel_plan (int n, int m, int r[][2], int l[], int k, int p[]) {
	//make graph
	vector<pair<int, int>> g[n];
	for (int i = 0; i < m; i++) {
		int u = r[i][0], v = r[i][1];
		g[u].push_back(make_pair(v, l[i]));
		g[v].push_back(make_pair(u, l[i]));
	}
	//know how many exits have each vertex
	set<pair<int, int>> can_exit[n];
	for (int i = 0; i < k; i++) {
		int exit = p[i];
		for (auto u : g[exit]) {
			can_exit[u.first].insert(make_pair(u.second, exit));
		}
	}
	//dijkstra
	int sol = 1e9;
	vector<int> dist(n, INF);
	priority_queue<pair<int, int>> pq;
	bool vis[n];
	memset(vis, false, sizeof(vis));
	pq.push(make_pair(0, 0));
	dist[0] = 0;
	while (!pq.empty()) {
		int v = pq.top().s;
		int cur = pq.top().f;
		pq.pop();
		if (vis[v]) continue;
		vis[v] = true;
		if (len(can_exit[v]) >= 2) {
			auto last = can_exit[v].rbegin();
			last--;
			pair<int, int> cost = *last
			sol = min(sol, cost.f + cur);
			continue;
		}
		for (auto u : g[v]) {
			if (dist[u.f] > dist[v] + u.s) {
				dist[u.f] = dist[v] + u.s;
				pq.push(make_pair(-dist[u.f], u.f));
			}
		}
	}
	return sol;
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:47:4: error: expected ',' or ';' before 'sol'
   47 |    sol = min(sol, cost.f + cur);
      |    ^~~
crocodile.cpp:39:7: warning: unused variable 'cur' [-Wunused-variable]
   39 |   int cur = pq.top().f;
      |       ^~~