#include #include using namespace std; int main(){ int m, n; cin >> n >> m; // cout << "check bounds on m and n" << endl; if(m <=0) // cout << "VALUE OF M TOO LOW" << endl; return 1; if(n > 100) // cout << "VALUE OF M TOO HIGH" << endl; return 2; if(n <= 0) // cout << "VALUE OF N TOO LOW" << endl; return 3; if(m > 4500) // cout << "VALUE OF N TOO HIGH" << endl; return 4; vector names(n+1); names[0] = "English"; // cout << "Reading in and checking destination languages" << endl; for(int i = 1; i <= n; i++){ string temp; cin >> temp; if(temp == "English") // cout << "ENGLISH CANNOT BE A DESTINATION LANGUAGE" << endl; return 5; for(int j = 0; j < i; j++) if(temp==names[j]) // cout << "LANGUAGE" << temp << " APPEARS TWICE" << endl; return 6; names[i] = temp; } /* vector > edges(n+1); for(int i = 0; i < n; i++){ edges[i].resize(n+1, false); } */ vector > edges; vector edgeList; for (int k=0;k<=n;k++) edgeList.push_back(false); for (int k=0;k<=n;k++) edges.push_back(edgeList); // cout << "Reading in and checking translations" << endl; for(int j = 0; j < m; j++){ string first; string second; int cost; cin >> first >> second >> cost; if(cost <= 0) // cout << "COST BETWEEN " << first << " AND " << second << " IS NOT POSITIVE" << endl; return 7; int first_pos = -1; for(int i = 0; i < names.size(); i++){ if(names[i] == first) first_pos = i; } if(first_pos == -1) // cout << "LANGUAGE " << first << " NOT FOUND" << endl; return 8; int second_pos = -1; for(int i = 0; i < names.size(); i++) if(names[i] == second) second_pos = i; if(second_pos == -1) // cout << "LANGUAGE " << second << " NOT FOUND " << endl; return 9; if(edges[first_pos][second_pos] || edges[second_pos][first_pos]) // cout << "ALREADY HAVE TRANSLATION BETWEEN " << first << " AND " << second<< endl; return 10; edges[first_pos][second_pos] = true; edges[second_pos][first_pos] = true; } return 42; }