CodeForces 19A World Football Cup
4135 단어 codeforces
Everyone knows that 2010 FIFA World Cup is being held in South Africa now. By the decision of BFA (Berland's Football Association) next World Cup will be held in Berland. BFA took the decision to change some World Cup regulations:
You are asked to write a program that, by the given list of the competing teams and the results of all the matches, will find the list of teams that managed to get through to the knockout stage.
Input
The first input line contains the only integer n (1 ≤ n ≤ 50) — amount of the teams, taking part in the final tournament of World Cup. The following n lines contain the names of these teams, a name is a string of lower-case and upper-case Latin letters, its length doesn't exceed 30 characters. The following n·(n - 1) / 2 lines describe the held matches in the format name1-name2 num1:num2, wherename1, name2 — names of the teams; num1, num2 (0 ≤ num1, num2 ≤ 100) — amount of the goals, scored by the corresponding teams. Accuracy of the descriptions is guaranteed: there are no two team names coinciding accurate to the letters' case; there is no match, where a team plays with itself; each match is met in the descriptions only once.
Output
Output n / 2 lines — names of the teams, which managed to get through to the knockout stage in lexicographical order. Output each name in a separate line. No odd characters (including spaces) are allowed. It's guaranteed that the described regulations help to order the teams without ambiguity.
Sample Input
Input
4
A
B
C
D
A-B 1:1
A-C 2:2
A-D 1:0
B-C 1:0
B-D 0:3
C-D 0:3
Output
A
D
Input
2
a
A
a-A 2:1
Output
a
축구 경기를 모의하여 출전 상황을 계산하다.요구에 따라 두 순서로 배열하면 된다.
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<cstdio>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long LL;
const int low(int x){ return x&-x; }
const int INF = 0x7FFFFFFF;
const int mod = 1e9 + 7;
const int maxn = 5e2 + 10;
int T, n, x, y;
int a[maxn], b[maxn], c[maxn], ans[maxn];
char name[maxn][maxn], s1[maxn], s2[maxn], s[maxn];
bool cmp1(const int &x, const int &y)
{
return a[x] == a[y] ? (b[x] - c[x]) == (b[y] - c[y]) ? b[x] > b[y]:(b[x] - c[x]) > (b[y] - c[y]) : a[x] > a[y];
}
bool cmp2(const int &x, const int &y)
{
return strcmp(name[x], name[y]) < 0;
}
int main()
{
while (scanf("%d", &n) != EOF)
{
map<string, int> M;
for (int i = 1; i <= n; i++)
{
scanf("%s", name[i]);
M[name[i]] = ans[i] = i;
a[i] = b[i] = c[i] = 0;
}
for (int i = 1, j, k; i + i <= n*(n - 1); i++)
{
scanf("%s%d:%d", s, &x, &y);
for (j = 0; s[j] != '-'; j++) s1[j] = s[j];
s1[j++] = 0;
for (k = j; s[k]; k++) s2[k - j] = s[k];
s2[k - j] = 0;
int fx = M[s1], fy = M[s2];
b[fx] += x; c[fx] += y;
b[fy] += y; c[fy] += x;
if (x == y) a[fx]++, a[fy]++;
else a[x > y ? fx : fy] += 3;
}
sort(ans + 1, ans + n + 1, cmp1);
sort(ans + 1, ans + n / 2 + 1, cmp2);
for (int i = 1; i + i <= n; i++) printf("%s
", name[ans[i]]);
}
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Codeforces Round #715 Div. 2C The Sports Festival: 구간 DP전형구간 DP의 초전형. 이하, 0-indexed. 입력을 정렬하여 어디서나 시작하고 최적으로 좌우로 계속 유지하면 좋다는 것을 알 수 있습니다. {2000})$의 주문이 된다. 우선, 입력을 소트하여 n개의 요소를 $...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.