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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:7:2: error: 'map' was not declared in this scope
  map<int,int> koneet[n];
  ^~~
input/code.cpp:7:2: note: suggested alternative: 'main'
  map<int,int> koneet[n];
  ^~~
  main
input/code.cpp:7:6: error: expected primary-expression before 'int'
  map<int,int> koneet[n];
      ^~~
input/code.cpp:13:3: error: 'koneet' was not declared in this scope
   koneet[c0][c1]=c2
   ^~~~~~
input/code.cpp:13:3: note: suggested alternative: 'mode_t'
   koneet[c0][c1]=c2
   ^~~~~~
   mode_t
input/code.cpp:18:2: error: 'Crossroads' was not declared in this scope
  Crossroads(1,0,0);
  ^~~~~~~~~~
input/code.cpp:21:5: error: expected primary-expression before 'return'
     return 0;
     ^~~~~~
input/code.cpp:16:6: warning: unused variable 'total' [-Wunused-variable]
  int total = 0;
      ^~~~~
input/code.cpp: At global scope:
input/code.cpp:23:1: error: 'map' does not name a type; did you mean 'main'?
 map<int,int> Crossroads(int kone,int...

Code

#include <iostream>
using namespace std;

int main(){
	int n;
	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
	}
	int total = 0;

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

    return 0;
}
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;
}