#ifdef ONLINE_JUDGE #include #else #include #include #include #include #include #include #include #include #include #include #include #include #include #endif using namespace std; // lambda : [] (int a, int b) -> bool { body return } // string r_str = R"(raw string)" #define mp make_pair #define eb emplace_back #define pb push_back #define LL long long #define ULL unsigned long long #define BASE 73 #define NMAX 10000 #define NMAX2 20001 #define MOD1 1000000007 #define ALL(V) (V).begin(), (V).end() #define ALLR(V) (V).rbegin(), (V).rend() #define CRLINE Duxar(__LINE__); #define SHOWME(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl; #define ENTER putchar('\n'); void Duxar(int _this_line) { #ifndef ONLINE_JUDGE printf("\n . . . . . . . . . . . . . Passed line - %d\n", _this_line); #endif } template void ReadNo(T &_value) { T sign = 1; char ch; _value = 0; while(!isdigit(ch = getchar())) { (ch == '-') && (sign = -1); } do { _value = _value * 10 + (ch - '0'); } while(isdigit(ch = getchar())); _value *= sign; } template void AddNr(T &a, T b) { a = a + b; while (a >= MOD1) { a -= MOD1; } while (a < 0) { a += MOD1; } } map > stats; struct Team { string name; int pct, goal; }; bool cmp(Team A, Team B) { if (A.pct == B.pct && B.goal == A.goal) { return A.name < B.name; } if (A.pct == B.pct) { return A.goal > B.goal; } return A.pct > B.pct; } vector all_teams(4); int main(){ #ifndef ONLINE_JUDGE freopen("input.cpp", "r", stdin); #endif int i, g1, g2; string team1, team2; pair pr; for (i = 0; i < 6; ++i) { cin >> team1 >> team2 >> g1 >> g2; if (g1 == g2) { stats[team1].first++; stats[team1].second += g1; stats[team2].first++; stats[team2].second += g2; } if (g1 < g2) { swap(team2, team1); swap(g1, g2); } if (g1 > g2) { stats[team1].first += 3; stats[team1].second += g1; stats[team2].second += g2; } } i = 0; for (auto x: stats) { all_teams[i].name = x.first; all_teams[i].pct = x.second.first; all_teams[i].goal = x.second.second; ++i; } sort(ALL(all_teams), cmp); for (auto t: all_teams) { cout << t.name; ENTER; } return 0; }