#include<iostream> #include<cstring> #include<cstdlib> #include<algorithm> using namespace std; struct tabela { char nume[101]; int goluri, puncte; }echipe[5], meci[3]; inline bool cmd (tabela x, tabela y) { return x.puncte<y.puncte; } char s[202],nume_echipa[101]; void citire() {int j,l,ok1=0,ok2=0; for(int i=1;i<=6;i++) { cin.getline(s, 202); for(j=0;j<strlen(s);j++) { if(s[j]==' ') { strcpy(meci[1].nume, nume_echipa); strcpy(s,s+j+1); break; } else { nume_echipa[j]=s[j]; } } for(j=0;j<strlen(s);j++) nume_echipa[j]=NULL; for(j=0;j<strlen(s);j++) { if(s[j]==' ') { strcpy(meci[2].nume, nume_echipa); strcpy(s,s+j+1); break; } else { nume_echipa[j]=s[j]; } } for(j=0;j<strlen(s);j++) nume_echipa[j]=NULL; for(j=0;j<strlen(s);j++) { if(s[j]==' ') { meci[1].goluri=atoi(nume_echipa); strcpy(s,s+j+1); } else { nume_echipa[j]=s[j]; } } for(j=0;j<strlen(s);j++) nume_echipa[j]=NULL; for(j=0;j<strlen(s);j++) { if(s[j]==' ') { meci[2].goluri=atoi(nume_echipa); strcpy(s,s+j+1); } else { nume_echipa[j]=s[j]; } } for(j=0;j<strlen(s);j++) nume_echipa[j]=NULL; if(meci[1].goluri>meci[2].goluri) { meci[1].puncte=meci[1].puncte+3; } else { if(meci[1].goluri==meci[2].goluri) meci[1].puncte=meci[1].puncte+1, meci[2].puncte=meci[2].puncte+1; else meci[2].puncte=meci[2].puncte+3; } ok1=0; ok2=0; for(l=1;l<=5;l++) { if(strcmp(echipe[l].nume,meci[1].nume)) { echipe[l].goluri=echipe[l].goluri+meci[1].goluri; echipe[l].puncte=echipe[l].puncte+meci[1].puncte; ok1=1; } if(strcmp(echipe[l].nume,meci[2].nume)) { echipe[l].goluri=echipe[l].goluri+meci[2].goluri; echipe[l].puncte=echipe[l].puncte+meci[2].puncte; ok2=1; } if(ok1==0) { if(echipe[l].nume==0) { echipe[l].nume=meci[1].nume; echipe[l].goluri=echipe[l].goluri+meci[1].goluri; echipe[l].puncte=echipe[l].puncte+meci[1].puncte; } } if(ok2==0) { if(echipe[l].nume==0) { echipe[l].nume=meci[2].nume; echipe[l].goluri=echipe[l].goluri+meci[2].goluri; echipe[l].puncte=echipe[l].puncte+meci[2].puncte; } } } } sort(echipe,echipe+5,cmd); for(int i=1;i<=5;i++) { if(echipe[i].puncte==echipe[i+1].puncte) if(echipe[i].goluri==echipe[i+1].goluri) cout<<echipe[i].nume<<'\n'; else cout<<echipe[i+1].nume<<'\n'; else cout<<echipe[i].nume<<'\n'; } } int main () { citire(); return 0; }