CSES - Datatähti 2016 alku - Results
Submission details
Task:Lennot
Sender:Chatne
Submission time:2015-10-10 23:40:05
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp:11:11: error: '::main' must return 'int'
 void main() {
           ^

Code

#include <iostream>
#include <map>
#include <vector>

using namespace std;

long long city, flights;
vector<long long> prices;
map<long long, vector<vector<long long>>> flist;

void main() {

	cin.sync_with_stdio(false);
	cin >> city >> flights;

	for (long long i = 0; i < flights; i++) {
		long long a, b, c;
		cin >> a >> b >> c;

		flist[a].push_back({ b, c });
	}

	void recursive(long long curcity, vector<long long> visited, vector<long long> costlist);

	vector<long long> visited(city, 0);
	recursive(1, visited, {});

	long long cheap = prices[0];
	for (long long i = 0; i < (long long)prices.size(); i++) {
		if (prices[i] < cheap) {
			cheap = prices[i];
		}
	}
	cout << cheap;
}

void recursive(long long curcity, vector<long long> visited, vector<long long> costlist) {
	if (curcity == city) {
		bool free = false;
		long long total = 0;
		for (long long i = 0; i < (long long)costlist.size(); i++) {
			if (free) {
				free = false;
			}
			else {
				total += costlist[i];
				free = true;
			}
		}
		prices.push_back(total);
	}
	else {
		vector<long long> cango;
		for (long long i = 0; i < (long long)flist[curcity].size(); i++) {
			if (visited[flist[curcity][i][0] - 1] == 0) {
				cango.push_back(i);
			}
		}
		visited[curcity - 1] = 1;

		for (long long i = 0; i < (long long)cango.size(); i++) {
			vector<long long> costlistnew = costlist;
			costlistnew.push_back(flist[curcity][cango[i]][1]);
			recursive(flist[curcity][cango[i]][0], visited, costlistnew);
		}
	}
}