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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:19:3: error: expected ';' before 'koneet'
   koneet[c1][c0]=c2
   ^~~~~~
input/code.cpp:21:62: 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);
  ^~~~~~~~~~
input/code.cpp:43:12: error: '::total' has not been declared
  cout << ::total;
            ^~~~~
input/code.cpp:10:6: warning: unused variable 'total' [-Wunused-variable]
  int total = 0;
      ^~~~~

Code

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



int 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;

    return 0;
}