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

Compiler report

input/code.cpp:3:12: error: 'std::map' has not been declared
 using std::map;
            ^~~
input/code.cpp:8:6: error: 'map' in namespace 'std' does not name a template type
 std::map<int,int> Crossroads(int kone,int source,int sourceSpeed){
      ^~~
input/code.cpp: In function 'int main()':
input/code.cpp:31:7: error: 'map' is not a member of 'std'
  std::map<int,int> ::koneet[n];
       ^~~
input/code.cpp:31:7: note: suggested alternative: 'max'
  std::map<int,int> ::koneet[n];
       ^~~
       max
input/code.cpp:31:11: error: expected primary-expression before 'int'
  std::map<int,int> ::koneet[n];
           ^~~
input/code.cpp:37:3: error: 'koneet' was not declared in this scope
   koneet[c0][c1]=c2
   ^~~~~~
input/code.cpp:37:3: note: suggested alternative: 'mode_t'
   koneet[c0][c1]=c2
   ^~~~~~
   mode_t
input/code.cpp:41:2: error: 'Crossroads' was not declared in this scope
  Crossroads(1,0,0);
  ^~~~~~~~~~

Code

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

int total = 0;


std::map<int,int> Crossroads(int kone,int source,int sourceSpeed){
	std::map<int,int> yhteydet;
	yhteydet[sourceSpeed] = 1;
	int addTotal = 0;
	
	std::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;
}
int main(){
	int n;
	cin >> n;
	std::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
	}

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

    return 0;
}