博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Gym - 101194L World Cup 暴力
阅读量:5117 次
发布时间:2019-06-13

本文共 7017 字,大约阅读时间需要 23 分钟。

World Cup

Input file: Standard Input
Output file: Standard Ouptut
Time limit: 1 second

Here 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 same
group will play a game (so there are totally 6 games in each group), and the winner of this game
gets 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 you
help us to figure the result of each game? We only care about the win/lose/tie result of each
game, but we don’t care the goals in each game.
Input
The 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 the
points each team gets after all 6 games.
Output
For 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 are
multiple game results satisfy the scoreboard, or “Wrong Scoreboard” if there is no game result
matches the scoreboard.

Limits

• 1 ≤ T ≤ 100.
• 0 ≤ A, B, C, D ≤ 100.

Sample Input

3
9 6 3 0
6 6 6 0
10 6 3 0

Sample Output

Case #1: Yes
Case #2: No
Case #3: Wrong Scoreboard

Note
In sample case #1, the only scenaro will be: the first team wins all the three games it plays, the
second team loses to the first team and wins the other two, the third team only wins the game
with 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 a
winning-cycle, but there may be two different winning-cycles: first team wins second team, second
team wins third team, third team wins first team OR first team wins third team, third team wins
second team, second team wins first team. We can’t figure which winning-cycle is the actual game
result.
In sample case #3, the first team get 10 points, but no team could get more than 9 points by
play three games, so it is a wrong scoreboard.

 

大意:根据世界杯赛制, 每轮有四场比赛, 每支队伍与其他三支队伍各打一场比赛, 一共有六场比赛。给出四支球队分别的得分,能否确定唯一的胜负关系。

思路:此题可以暴力枚举出所有的情况与输入分数进行匹配。根据匹配成功的次数可以判断最终结果。

 

#include
using 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"); } }}

 

转载于:https://www.cnblogs.com/YY666/p/11225761.html

你可能感兴趣的文章
sql server必知多种日期函数时间格式转换
查看>>
jQuery EasyUI 的下拉选择combobox后台动态赋值
查看>>
timeline时间轴进度“群英荟萃”
查看>>
python if else elif statement
查看>>
网络编程
查看>>
文本隐藏(图片代替文字)
查看>>
java面试题
查看>>
提高码力专题(未完待续)
查看>>
pair的例子
查看>>
前端框架性能对比
查看>>
@property中 retain 详解
查看>>
uva 387 A Puzzling Problem (回溯)
查看>>
12.2日常
查看>>
Delphi 取整函数round、trunc、ceil和floor
查看>>
C/C++二维数组的用法
查看>>
排序 冒泡排序法
查看>>
同步代码时忽略maven项目 target目录
查看>>
MVC.NET:提供对字体文件.woff的访问
查看>>
Informatica_(2)第一个例子
查看>>
string 常用函数
查看>>