Submission #123602

# Submission time Handle Problem Language Result Execution time Memory
123602 2019-07-01T18:00:59 Z johutha Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include "crocodile.h"
#include <vector>

#define int int64_t

using namespace std;

vector<int> vals;

vector<vector<pair<int,int>>> adjlist;

int dfs(int curr, int prev)
{
	if (vals[curr] != -1) return vals[curr];
	vals[curr] = 1e14;
	int fr = 1e14;
	int sec = 1e14;

	for (auto p : adjlist[curr])
	{
		int next = p.first;
		if (next == prev) continue;
		int val = dfs(next, curr) + p.second;
		if (val <= fr)
		{
			sec = fr;
			fr = val;
		}
		else if (val <= sec)
		{
			sec = val;
		}
	}

	return vals[curr] = sec;
}

int travel_plan(int n, int m, int R[][2], int L[], int k, int P[])
{
	vals.resize(n, -1);
	for (int i = 0; i < k; i++)
	{
		vals[P[i]] = 0;
	}
	adjlist.resize(n);
	for (int i = 0; i < m; i++)
	{
		adjlist[R[i][0]].push_back({R[i][1], L[i]});
		adjlist[R[i][1]].push_back({R[i][0], L[i]});
	}
	return dfs(0, -1);
}

Compilation message

crocodile.cpp:4:13: error: 'int64_t' was not declared in this scope
 #define int int64_t
             ^
crocodile.cpp:8:8: note: in expansion of macro 'int'
 vector<int> vals;
        ^~~
crocodile.cpp:8:11: error: template argument 1 is invalid
 vector<int> vals;
           ^
crocodile.cpp:8:11: error: template argument 2 is invalid
crocodile.cpp:4:13: error: 'int64_t' was not declared in this scope
 #define int int64_t
             ^
crocodile.cpp:10:20: note: in expansion of macro 'int'
 vector<vector<pair<int,int>>> adjlist;
                    ^~~
crocodile.cpp:4:13: error: 'int64_t' was not declared in this scope
 #define int int64_t
             ^
crocodile.cpp:10:24: note: in expansion of macro 'int'
 vector<vector<pair<int,int>>> adjlist;
                        ^~~
crocodile.cpp:4:13: error: template argument 1 is invalid
 #define int int64_t
             ^
crocodile.cpp:10:24: note: in expansion of macro 'int'
 vector<vector<pair<int,int>>> adjlist;
                        ^~~
crocodile.cpp:4:13: error: template argument 2 is invalid
 #define int int64_t
             ^
crocodile.cpp:10:24: note: in expansion of macro 'int'
 vector<vector<pair<int,int>>> adjlist;
                        ^~~
crocodile.cpp:10:27: error: template argument 1 is invalid
 vector<vector<pair<int,int>>> adjlist;
                           ^~
crocodile.cpp:10:27: error: template argument 2 is invalid
crocodile.cpp:10:29: error: template argument 1 is invalid
 vector<vector<pair<int,int>>> adjlist;
                             ^
crocodile.cpp:10:29: error: template argument 2 is invalid
crocodile.cpp:4:13: error: 'int64_t' does not name a type
 #define int int64_t
             ^
crocodile.cpp:12:1: note: in expansion of macro 'int'
 int dfs(int curr, int prev)
 ^~~
crocodile.cpp:4:13: error: 'int64_t' does not name a type
 #define int int64_t
             ^
crocodile.cpp:38:1: note: in expansion of macro 'int'
 int travel_plan(int n, int m, int R[][2], int L[], int k, int P[])
 ^~~