CSES - Datatähti 2022 alku - Results
Submission details
Task:Tietoverkko
Sender:okkokko
Submission time:2021-10-12 15:38:46 +0300
Language:C++11
Status:COMPILE ERROR

Compiler report

input/code.cpp:8:11: error: '::main' must return 'int'
 void main(){
           ^
input/code.cpp: In function 'int main()':
input/code.cpp:21:63: error: a function-definition is not allowed here before '{' token
  map<int,int> Crossroads(int kone,int source,int sourceSpeed) {
                                                               ^
input/code.cpp:42:2: error: 'Crossroads' was not declared in this scope
  Crossroads(1,0,0);
  ^~~~~~~~~~

Code

#include <iostream>
#include <map>
using namespace std;
using std::map;



void main(){
	int n;
	int total = 0;
	cin >> n;
	map<int,int> koneet[n];
	for (int i = 0; i<n; i++){
		int c0,c1,c2;
		cin >> c0;
		cin >> c1;
		cin >> c2;
		koneet[c0][c1]=c2;
		koneet[c1][c0]=c2;
	}
	map<int,int> Crossroads(int kone,int source,int sourceSpeed) {
		map<int,int> yhteydet;
		yhteydet[sourceSpeed] = 1;
		int addTotal = 0;
	
		map<int,int> &ko = koneet[kone];
		/*
		map<int, int>::iterator itr;
		for (itr=ko.begin();itr!=ko.end();++itr){
	
		}*/
		for (auto &item : ko){
			if (item.first !=source){
				Crossroads(item.first,kone,item.second);
			}
		}
		total+=addTotal;

		return yhteydet;
	}

	Crossroads(1,0,0);
	cout << total;

}