Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <algorithm>
- #include <string>
- #include <cstring>
- #include <map>
- #define N 100
- using namespace std;
- struct three
- {
- int points, scored, missed;
- };
- struct team
- {
- string name;
- three result;
- team() {}
- team(string s, three a)
- {
- name = s, result = a;
- }
- };
- bool operator < (team a1, team a2)
- {
- if (a1.result.points == a2.result.points &&
- a1.result.scored - a1.result.missed == a2.result.scored - a2.result.missed)
- return a1.result.scored > a2.result.scored;
- if (a1.result.points == a2.result.points)
- return a1.result.scored - a1.result.missed > a2.result.scored - a2.result.missed;
- return a1.result.points > a2.result.points;
- }
- char team1[N], match[N];
- map<string, three> table;
- string out[N];
- team res[N];
- int main()
- {
- int n;
- scanf("%d", &n);
- for (int i = 0; i < n; i++)
- {
- string name;
- scanf("%s", team1);
- name = team1;
- table[name].points = table[name].scored = table[name].missed = 0;
- }
- for (int i = 0; i < (n - 1) * n / 2; i++)
- {
- scanf("%s", match);
- string t1 = "", t2 = "";
- int len = strlen(match), j = 0;
- for (j = 0; ; j++)
- {
- if (match[j] == '-') break;
- t1 += match[j];
- }
- j++;
- for (; j < len; j++)
- {
- if (match[j] == '-') break;
- t2 += match[j];
- }
- int score1, score2;
- scanf("%d%*c%d", &score1, &score2);
- table[t1].scored += score1;
- table[t2].scored += score2;
- table[t1].missed += score2;
- table[t2].missed += score1;
- if (score1 == score2)
- table[t1].points++, table[t2].points++;
- if (score1 > score2)
- table[t1].points += 3;
- if (score1 < score2)
- table[t2].points += 3;
- }
- int j = 0;
- for (map<string, three>::iterator i = table.begin(); i != table.end(); i++)
- res[j++] = team((*i).first, (*i).second);
- sort(res, res + j);
- for (int i = 0; i < n/ 2; i++)
- out[i] = res[i].name;
- sort(out, out + n / 2);
- for (int i = 0; i < n / 2; i++)
- printf("%s\n", out[i].c_str());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement