Task: | Tietoverkko |
Sender: | okkokko |
Submission time: | 2021-10-12 15:26:36 +0300 |
Language: | C++ (C++11) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'std::map<int, int> Crossroads(int, int, int)': input/code.cpp:14:23: error: '::koneet' has not been declared map<int,int> &ko = ::koneet[kone]; ^~~~~~ input/code.cpp:14:23: note: suggested alternative: 'kone' map<int,int> &ko = ::koneet[kone]; ^~~~~~ kone input/code.cpp: In function 'int main()': input/code.cpp:32:17: error: 'koneet' is not a member of 'std::map<int, int>' map<int,int> ::koneet[n]; ^~~~~~ input/code.cpp:38:3: error: 'koneet' was not declared in this scope koneet[c0][c1]=c2 ^~~~~~ input/code.cpp:38:3: note: suggested alternative: 'mode_t' koneet[c0][c1]=c2 ^~~~~~ mode_t
Code
#include <iostream> #include <map> using namespace std; using std::map; int total = 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; } 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 } Crossroads(1,0,0); cout << ::total; return 0; }