【HDU - 5873】Football Games(兰道定理,知识点总结)
題干:
A mysterious country will hold a football world championships---Abnormal Cup, attracting football teams and fans from all around the world. This country is so mysterious that none of the information of the games will be open to the public till the end of all the matches. And finally only the score of each team will be announced.?
??At the first phase of the championships, teams are divided into?MM?groups using the single round robin rule where one and only one game will be played between each pair of teams within each group. The winner of a game scores 2 points, the loser scores 0, when the game is tied both score 1 point. The schedule of these games are unknown, only the scores of each team in each group are available.?
??When those games finished, some insider revealed that there were some false scores in some groups. This has aroused great concern among the pubic, so the the Association of Credit Management (ACM) asks you to judge which groups' scores must be false.
Input
Multiple test cases, process till end of the input.?
??For each case, the first line contains a positive integers?MM, which is the number of groups.?
??The?ii-th of the next?MM?lines begins with a positive integer?BiBi?representing the number of teams in the?ii-th group, followed by?BiBi?nonnegative integers representing the score of each team in this group.?
number of test cases <= 10
M<= 100
B[i]<= 20000
score of each team <= 20000
Output
For each test case, output?MM?lines. Output ``F" (without quotes) if the scores in the i-th group must be false, output ``T" (without quotes) otherwise. See samples for detail.
Sample Input
2 3 0 5 1 2 1 1Sample Output
F T題目大意:
每組樣例占一行,先給定一個數n,緊接著有n個數。
有n支足球隊,每兩支隊伍都要比一場,贏了得2分,輸了得0分,平局雙方各得1分。給定n個球隊的得分情況,問是否合法。
解題報告:
首先來說明一下蘭道定理
蘭道定理又稱競賽圖定理,是一個定義在有向圖上的概念,顧名思義,它可以想象成n個人兩兩對決,贏得向輸的連邊,其實就是給一副完全圖的無向邊定了方向。
定義一個競賽圖的比分序列(score sequence),是把競賽圖的每一個點的出度從小到大排列得到的序列。
一個長度為n的序列
?? ?
是合法的比分序列當且僅當:且k==n的時候必須取等。
但是蘭道定理是贏的一方得一分,輸的一方不得分,似乎跟這道題不是很符合,但是你把它改為贏的一方得兩分,輸的一方不得分,平局各得一分,只需要把公式后面給C(2,K)乘2就好了。
AC代碼:代碼來自
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 20010; int a[MAXN]; int main() {int t;while(scanf("%d",&t) != EOF) {while(t--) {memset(a,0,sizeof(a));int n,i,sum = 0;bool flag = true;scanf("%d",&n);for(int i = 0; i < n; i++) {scanf("%d",&a[i]);sum += a[i];}if(sum != n*(n-1)) {flag = false;puts("F");continue;}sort(a,a+n);sum = 0;for(int i = 0; i < n-1; i++) {sum += a[i];if(sum >= (i + 1) * i) continue;else {flag = false;puts("F");break;}}if(flag) puts("T");}}return 0; }?
總結
以上是生活随笔為你收集整理的【HDU - 5873】Football Games(兰道定理,知识点总结)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: surveyor.exe - surve
- 下一篇: 【2019牛客暑期多校训练营(第一场)