2016亚洲区域赛现场赛china final L题

Problem L. 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 and output Sample Input Sample Output 3 9 6 3 0 6 6 6 0 10 6 3 0 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.
The 2016 ACM-ICPC Asia China-Final Contest
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.

题意:在一次比赛中,一个小组有四个队,每个队要与其他三个队都进行一场比赛,在一场比赛中,赢的那一个队获得三分,输的的那个队不得分,若是平局,则两个队都的一分。现在给你四个队的最终得分,问你能不能唯一确定每一场比赛的胜负情况,能的话输出yes,若是有多种得到该分数的方法,则输出no,若是没有一种方法能到该分数,则输出wrong scoreboard.
解题思路:最多3^6多种情况,直接预处理出所有的情况,就行,用6个for暴力弄一下就行。

#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
void solve()
{
    mp.clear();
    int A,B,C,D;
    for(int i = 0; i <= 2; i++)
    {
        for(int j = 0; j <= 2; j++)
        {
            for(int k = 0; k <= 2; k++)
            {
                for(int l = 0; l <= 2; l++)
                {
                    for(int m = 0; m <= 2; m++)
                    {
                        for(int n = 0; n <= 2; n++)
                        {
                            A = 0;
                            B = 0;
                            C = 0;
                            D = 0;
                            if(i == 0)
                            {
                                A += 3;
                            }
                            else if(i == 1)
                            {
                                B += 3;
                            }
                            else if(i == 2)
                            {
                                A += 1;
                                B += 1;
                            }

                            if(j == 0)
                            {
                                A += 3;
                            }
                            else if(j == 1)
                            {
                                C += 3;
                            }
                            else if(j == 2)
                            {
                                A += 1;
                                C += 1;
                            }

                            if(k == 0)
                            {
                                A += 3;
                            }
                            else if(k == 1)
                            {
                                D += 3;
                            }
                            else if(k == 2)
                            {
                                A += 1;
                                D += 1;
                            }

                            if(l == 0)
                            {
                                B += 3;
                            }
                            else if(l == 1)
                            {
                                C += 3;
                            }
                            else if(l == 2)
                            {
                                B += 1;
                                C += 1;
                            }

                            if(m == 0)
                            {
                                B += 3;
                            }
                            else if(m == 1)
                            {
                                D += 3;
                            }
                            else if(m == 2)
                            {
                                B += 1;
                                D += 1;
                            }

                            if(n == 0)
                            {
                                C += 3;
                            }
                            else if(n == 1)
                            {
                                D += 3;
                            }
                            else if(n == 2)
                            {
                                C += 1;
                                D += 1;
                            }
                            string s = "0000";
                            s[0] = A + '0';
                            s[1] = B + '0';
                            s[2] = C + '0';
                            s[3] = D + '0';
                            mp[s]++;
                        }
                    }
                }
            }
        }
    }
}
int main()
{
    int T;
    solve();
    scanf("%d",&T);
    int x1,x2,x3,x4;
    for(int ca = 1; ca <= T; ca++)
    {
        scanf("%d%d%d%d",&x1,&x2,&x3,&x4);
        string x = "0000";
        x[0] = '0' + x1;
        x[1] = '0' + x2;
        x[2] = '0' + x3;
        x[3] = '0' + x4;
        printf("Case #%d: ",ca);
        if(mp[x] == 1)
        {
            printf("Yes\n");
        }
        else if(mp[x] >= 2)
        {
            printf("No\n");
        }
        else printf("Wrong Scoreboard\n");
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值