World Cup
Input file: Standard InputOutput file: Standard OuptutTime limit: 1 secondHere is World Cup again, the top 32 teams come together to fight for the World Champion.
The teams are assigned into 8 groups, with 4 teams in each group. Every two teams in the samegroup will play a game (so there are totally 6 games in each group), and the winner of this gamegets 3 points, loser gets 0 point. If it is a tie game, both teams get 1 point.After all games finished, we get the scoreboard, but we forget the result of each game, can youhelp us to figure the result of each game? We only care about the win/lose/tie result of eachgame, but we don’t care the goals in each game.InputThe input starts with one line containing exactly one integer T, which is the number of test cases.Each test case contains four space-separated integers A, B, C, D, in a line, which indicate thepoints each team gets after all 6 games.OutputFor each test case, output one line containing Case #x: y, where x is the test case number(starting from 1) and y is “Yes” if you can point out the result of each game, or “No” if there aremultiple game results satisfy the scoreboard, or “Wrong Scoreboard” if there is no game resultmatches the scoreboard.Limits
• 1 ≤ T ≤ 100.• 0 ≤ A, B, C, D ≤ 100.Sample Input
39 6 3 06 6 6 010 6 3 0Sample Output
Case #1: YesCase #2: NoCase #3: Wrong Scoreboard NoteIn sample case #1, the only scenaro will be: the first team wins all the three games it plays, thesecond team loses to the first team and wins the other two, the third team only wins the gamewith the fourth, and the fourth team lose all the games.In sample case #2, the fourth team loses all the games, and the first three teams get into awinning-cycle, but there may be two different winning-cycles: first team wins second team, secondteam wins third team, third team wins first team OR first team wins third team, third team winssecond team, second team wins first team. We can’t figure which winning-cycle is the actual gameresult.In sample case #3, the first team get 10 points, but no team could get more than 9 points byplay three games, so it is a wrong scoreboard.
大意:根据世界杯赛制, 每轮有四场比赛, 每支队伍与其他三支队伍各打一场比赛, 一共有六场比赛。给出四支球队分别的得分,能否确定唯一的胜负关系。
思路:此题可以暴力枚举出所有的情况与输入分数进行匹配。根据匹配成功的次数可以判断最终结果。
#includeusing namespace std;int score[4];int cnt;int gget[4];int main(){#ifndef ONLINE_JUDGE freopen("in.txt", "r",stdin); freopen("out.txt", "w",stdout);#endif // ONLINE_JUDGE int T; cin >> T; for(int t = 1; t <= T; t++) { printf("Case #%d: ", t); int sum; for(int i = 0; i < 4; i++) cin >> score[i]; cnt = 0; for(int g1 = -1; g1 < 2; g1++) for(int g2 = -1; g2 < 2; g2++) for(int g3 = -1; g3 < 2; g3++) for(int g4 = -1; g4 < 2; g4++) for(int g5 = -1; g5 < 2; g5++) for(int g6 = -1; g6 < 2; g6++) { memset(gget,0,sizeof(gget)); if(g1 == 1) { gget[0] += 3; } else if(g1 == 0) { gget[0] += 1; gget[1] += 1; } else if(g1 == -1) { gget[1] += 3; } if(g2 == 1) { gget[0] += 3; } else if(g2 == 0) { gget[0] += 1; gget[2] += 1; } else if(g2 == -1) { gget[2] += 3; } if(g3 == 1) { gget[0] += 3; } else if(g3 == 0) { gget[0] += 1; gget[3] += 1; } else if(g3 == -1) { gget[3] += 3; } if(g4 == 1) { gget[1] += 3; } else if(g4 == 0) { gget[1] += 1; gget[2] += 1; } else if(g4 == -1) { gget[2] += 3; } if(g5 == 1) { gget[1] += 3; } else if(g5 == 0) { gget[1] += 1; gget[3] += 1; } else if(g5 == -1) { gget[3] += 3; } if(g6 == 1) { gget[2] += 3; } else if(g6 == 0) { gget[2] += 1; gget[3] += 1; } else if(g6 == -1) { gget[3] += 3; }// for(int i = 0; i < 4; i++)// cout << gget[i] << " ";// cout << endl; int flag = 1; for(int i = 0; i < 4; i++) if(score[i] != gget[i]) flag = 0; if(flag)cnt++; } //printf("cnt:%d\n",cnt); if(cnt == 0) { printf("Wrong Scoreboard\n"); } else if(cnt == 1) { printf("Yes\n"); } else { printf("No\n"); } }}