2016EC-final L题World Cup

2016EC-final L题World Cup

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.
Notes:
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 winningcycle, 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.
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

题意:

一个小组4个队伍打满6场比赛,我们把所有的对位信息都标出来过后爆搜就行了。

#include<bits/stdc++.h>
using namespace std;
int score[5];
int a[6][2]={{0,1},{0,2},{0,3},{1,2},{1,3},{2,3}};
//分别六场的对局信息
int cnt;
void dfs(int now)
{
    if(now==6){
        if(!score[0]&&!score[1]&&!score[2]&&!score[3]) cnt++;
        return ;
    }
    score[a[now][0]]-=3;//前者胜
    dfs(now+1);
    score[a[now][0]]+=3;
    score[a[now][0]]-=1;//两者平
    score[a[now][1]]-=1;
    dfs(now+1);
    score[a[now][0]]+=1;
    score[a[now][1]]+=1;
    score[a[now][1]]-=3;//后者胜
    dfs(now+1);
    score[a[now][1]]+=3;
}
int main()
{
    int t; scanf("%d",&t);
    int cas=1;
    while(t--){
        cnt=0;
        scanf("%d%d%d%d",score+0,score+1,score+2,score+3);
        dfs(0);
        printf("Case #%d: ",cas++);
        if(cnt==1) puts("Yes");
        else if(cnt>1) puts("No");
        else puts("Wrong Scoreboard");
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值