#include #include #include #include using namespace std; int gol1, gol2, NRGOLDATE[5], PUNCTE[5], nr_teams, i, j; char nume1[100], nume2[100], mat[6][100], aux[100]; int main() { #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); #endif // ONLINE_JUDGE for(i = 0; i < 6; i++) { cin >> nume1; cin >> nume2; cin >> gol1; cin >> gol2; for(j = 1; j <= nr_teams; j++) { if(strcmp(mat[j], nume1) == 0) { NRGOLDATE[j] += gol1; break; } } if(j > nr_teams) { nr_teams++; strcpy(mat[nr_teams], nume1); NRGOLDATE[j] += gol1; } if(gol1 > gol2) PUNCTE[j] += 3; if(gol1 == gol2) PUNCTE[j]++; for(j = 1; j <= nr_teams; j++) { if(strcmp(mat[j], nume2) == 0) { NRGOLDATE[j] += gol2; break; } } if(j > nr_teams) { nr_teams++; strcpy(mat[nr_teams], nume2); NRGOLDATE[j] += gol2; } if(gol1 < gol2) PUNCTE[j] += 3; if(gol1 == gol2) PUNCTE[j]++; } for(i = 1;i <= 4; i++) { for(j = i + 1; j <= 4; j++) { if((PUNCTE[i] < PUNCTE[j]) || (PUNCTE[i] == PUNCTE[j] && NRGOLDATE[i] < NRGOLDATE[j]) || (PUNCTE[i] == PUNCTE[j] && strcmp(mat[i], mat[j]) > 0)) { strcpy(aux, mat[i]); strcpy(mat[i], mat[j]); strcpy(mat[j], aux); swap(PUNCTE[i], PUNCTE[j]); swap(NRGOLDATE[i], NRGOLDATE[j]); } } } for(i = 1; i <= 4; i++) { cout << mat[i] << '\n'; } return 0; }