#include #include #include using namespace std; struct echipa { char s[20]; int points, goals; }a[4]; int len, goals1, goals2; char team1[20], team2[20]; int find_team(char team[20]) { for(int i = 0; i < len; i++) if(strcmp(team, a[i].s) == 0) return i; strcpy(a[len++].s, team); return len-1; } void add_goals(char team[20], int goals) { a[find_team(team)].goals += goals; } void add_points(char team[20], int points) { a[find_team(team)].points += points; } void order() { for(int i = 0; i < 3; i++) for(int j = i + 1; j < 4; j++) { if(a[i].points < a[j].points) swap(a[i], a[j]); else if(a[i].points == a[j].points) { if(a[i].goals < a[j].goals) swap(a[i], a[j]); else if(a[i].goals == a[j].goals) if(strcmp(a[i].s, a[j].s) < 0) swap(a[i], a[j]); } } } void print() { for(int i = 0; i < 4; i++) cout << a[i].s << endl; } int main() { for(int i = 0; i < 6; i++) { cin >> team1 >> team2 >> goals1 >> goals2; add_goals(team1, goals1); add_goals(team2, goals2); if(goals1 == goals2) { add_points(team1, 1); add_points(team2, 1); } else if(goals1 > goals2) add_points(team1, 3); else if(goals1 < goals2) add_points(team2, 3); } order(); print(); return 0; }