题目:

  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.

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.

题意:世界杯比赛的一个小组中有4支队伍,队伍两两之间要进行一场比赛,赢得队伍得3分,输的队伍得0分,平局双方得1分。给出四支队伍的比赛完后的得分情况,问能不能确定具体的输赢情况。

思路:每组比赛一共有如下六种情况,那就dfs枚举六种情况下每个队伍输赢的所有的分情况,如果和给出的得分情况有多组相同,就是“No”,一组相同就是“Yes”,没有相同情况就是“Wrong Scoreboard”。

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 1e5+;
int a,b,c,d,ans;
int buf[]; void dfs(int x)
{
if(x == )
{
if(a == buf[] && b==buf[] && c==buf[]&& d==buf[])
ans++;
return;
}
if(x==)
{
buf[]+=;//1队伍赢
dfs(x+);
buf[]-=;
buf[]+=,buf[]+=;//两队平局
dfs(x+);
buf[]-=,buf[]-=;
buf[]+=;//2队伍赢
dfs(x+);
buf[]-=;
}
else if(x==)
{
buf[]+=;//1队伍赢
dfs(x+);
buf[]-=;
buf[]+=,buf[]+=;//两队平局
dfs(x+);
buf[]-=,buf[]-=;
buf[]+=;//3队伍赢
dfs(x+);
buf[]-=;
}
else if(x==)
{
buf[]+=;//1队伍赢
dfs(x+);
buf[]-=;
buf[]+=,buf[]+=;//两队平局
dfs(x+);
buf[]-=,buf[]-=;
buf[]+=;//4队伍赢
dfs(x+);
buf[]-=;
}
else if(x==)
{
buf[]+=;//2队伍赢
dfs(x+);
buf[]-=;
buf[]+=,buf[]+=;//两队平局
dfs(x+);
buf[]-=,buf[]-=;
buf[]+=;//3队伍赢
dfs(x+);
buf[]-=;
}
else if(x==)
{
buf[]+=;//2队伍赢
dfs(x+);
buf[]-=;
buf[]+=,buf[]+=;//两队平局
dfs(x+);
buf[]-=,buf[]-=;
buf[]+=;//4队伍赢
dfs(x+);
buf[]-=;
}
else if(x==)
{
buf[]+=;//3队伍赢
dfs(x+);
buf[]-=;
buf[]+=,buf[]+=;//两队平局
dfs(x+);
buf[]-=,buf[]-=;
buf[]+=;//4队伍赢
dfs(x+);
buf[]-=;
}
} int main()
{
int T,cnt = ;
scanf("%d",&T);
while(T--)
{
ans = ;
memset(buf,,sizeof(buf));
scanf("%d%d%d%d",&a,&b,&c,&d);
dfs();
if(ans==)
printf("Case #%d: Wrong Scoreboard\n",cnt++);
else if(ans == )
printf("Case #%d: Yes\n",cnt++);
else
printf("Case #%d: No\n",cnt++);
}
return ;
}

World Cup(The 2016 ACM-ICPC Asia China-Final Contest dfs搜索)的更多相关文章

  1. 2016 ACM/ICPC Asia Regional Dalian Online 1006 /HDU 5873

    Football Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  2. HDU 5873 Football Games 【模拟】 (2016 ACM/ICPC Asia Regional Dalian Online)

    Football Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  3. 2016 ACM/ICPC Asia Regional Shenyang Online 1003/HDU 5894 数学/组合数/逆元

    hannnnah_j’s Biological Test Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K ...

  4. 2016 ACM/ICPC Asia Regional Qingdao Online 1001/HDU5878 打表二分

    I Count Two Three Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  5. 2016 ACM/ICPC Asia Regional Shenyang Online 1009/HDU 5900 区间dp

    QSC and Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  6. 2016 ACM/ICPC Asia Regional Shenyang Online 1007/HDU 5898 数位dp

    odd-even number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  7. 2016 ACM/ICPC Asia Regional Dalian Online 1002/HDU 5869

    Different GCD Subarray Query Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K ( ...

  8. HDU 5874 Friends and Enemies 【构造】 (2016 ACM/ICPC Asia Regional Dalian Online)

    Friends and Enemies Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

  9. HDU 5889 Barricade 【BFS+最小割 网络流】(2016 ACM/ICPC Asia Regional Qingdao Online)

    Barricade Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  10. HDU 5875 Function 【倍增】 (2016 ACM/ICPC Asia Regional Dalian Online)

    Function Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total ...

随机推荐

  1. HTTP要点概述:五,HTTP的无状态性,持久连接,Cookie

    一,HTTP的无状态性: HTTP 是一种不保存状态,无状态(stateless)协议.HTTP 协议自身不对请求和响应之间的通信状态进行保存.也就是说在 HTTP 这个级别,协议对于发送过的请求或响 ...

  2. ‘CONFIG_ENV_SIZE’未声明(不在函数内【转】

    本文转载自: http://bbs.csdn.net/topics/390678466 见论坛讨论.可以临时修复.

  3. 洛谷 P1131 [ ZJOI 2007 ] 时态同步 —— 树形DP

    题目:https://www.luogu.org/problemnew/show/P1131 记录 x 子树内同步的时间 f[x],同步所需代价 g[x]: 直接转移即可,让该儿子子树与其它儿子同步, ...

  4. JeePlus:代码生成器-生成示例(操作)

    ylbtech-JeePlus:代码生成器-生成示例(操作) 1.返回顶部 1. 生成示例由以下部分组成 单表 主附表 树表 富文本 图片管理 自定义树组件 自定义Grid 多对多 左树右表 2. 2 ...

  5. 微信公众平台appid和appsecret在哪

    1.appid和appsecret是微信公众平台服务号才有的,如果自己家的公众平台不是服务号,需要升级为服务号. 2.登录服务号,登录“服务”条目,“服务中心”如图. 3.点击“自定义菜单”-“开发模 ...

  6. UVaLive 6834 Shopping (贪心)

    题意:给定 n 个商店,然后有 m个限制,去 c 之前必须先去d,问你从0到n+1,最短路程是多少. 析:我们我们要到c,必须要先到d,那么举个例子,2 5, 3 7,如果我们先到5再到2,再到7再到 ...

  7. P3626 [APIO2009]会议中心

    传送门 好迷的思路-- 首先,如果只有第一问就是个贪心,排个序就行了 对于第二问,我们考虑这样的一种构造方式,每一次都判断加入一个区间是否会使答案变差,如果不会的话就将他加入别问我正确性我不会证 我们 ...

  8. 数学/思维 UVA 11300 Spreading the Wealth

    题目传送门 /* 假设x1为1号给n号的金币数(逆时针),下面类似 a[1] - x1 + x2 = m(平均数) 得x2 = x1 + m - a[1] = x1 - c1; //规定c1 = a[ ...

  9. CodeDOMProvider 类

    CodeDomProvider 可用来创建和检索代码生成器和代码编译器的实例.代码生成器可以生成特定语言的代码,如:C#.Visual Basic.JScript 等,而代码编译器可以将代码文件编译成 ...

  10. 292 Nim Game Nim游戏

    您和您的朋友,两个人一起玩 Nim游戏:桌子上有一堆石头,每次你们轮流拿掉 1 到 3 块石头. 拿掉最后一块石头的人就是胜利者.由您来开局.你们两个都是聪明人,相信都有最佳的游戏策略. 请编写一个函 ...