#include #include #include #include #include using namespace std; struct TeamStats{ int points, goals; }; struct Team{ string name; TeamStats stats; }; bool SortFun(Team a, Team b){ if (a.stats.points > b.stats.points) return true; else if (a.stats.points < b.stats.points) return false; if (a.stats.goals > b.stats.goals) return true; else if (a.stats.goals > b.stats.goals) return false; if (a.name.compare(b.name) < 0) return true; else return false; } int main(){ map matches; string TeamA, TeamB; int GoalsA, GoalsB; while(true) { if (!((cin >> TeamA) && (cin >> TeamB) && (cin >> GoalsA) && (cin >> GoalsB))) break; matches[TeamA].goals += GoalsA; matches[TeamB].goals += GoalsB; if (GoalsA > GoalsB) matches[TeamA].points += 3; else if (GoalsA == GoalsB){ matches[TeamA].points ++; matches[TeamB].points ++; } else matches[TeamB].points += 3; } Team t; vector vTeam; for (map::iterator it = matches.begin(); it != matches.end(); it++){ t.name = it->first; t.stats = it->second; vTeam.push_back(t); } sort(vTeam.begin(), vTeam.end(), SortFun); for (vector::iterator it = vTeam.begin(); it != vTeam.end(); it++) cout << it->name << endl; return 0; }