题目分析:

对于A,B,C,D四支队伍,两两之间进行一场比赛,获胜得3分,平局得1分,失败不得分,现在对给出的四个队伍的得分,判断能否满足得到这种分数,且方案唯一输出yes,不唯一输出no,不可能则输出worng,由于一共只有6场比赛,直接通过暴力每一种可能,创建mat[i][j]存放队伍i和队伍j比赛对于i来说的得分,mat[j][i]存放对于j来说的得分,然后建立cal(int row,int col)深搜函数,对于每个mat[row][col]的结果都进行递归,查询得分为3,1,0的三种情况,然后再回溯,对于row和col下标到末尾是判断四支队伍的得分是否与输入相等,且需要注意的是mat[i][j]和mat[j][i]的得分是相对的(3对0,1对1用于最后删选去掉不可能的情况)

代码:

 #include<iostream>
#include<string.h>
using namespace std; int A, B, C, D;
int mat[][];
int ans; bool judge(){
int score[];
memset(score, , sizeof(score));
for(int i = ; i <= ; i++){
for(int j = ; j <= ; j++){
if(i != j){
score[i]+=mat[i][j];
if(mat[i][j] == && mat[j][i] != ) return false;
if(mat[i][j] == && mat[j][i] != ) return false;
if(mat[i][j] == && mat[j][i] != ) return false;
}
}
}
if(score[] == A && score[] == B && score[] == C && score[] == D){
return true;
}
else return false;
} void cal(int row, int col){
if(col == ){
cal(row+, );
return;
}
if(row == ){
if(judge()) ans++;
return;
} if(row != col){
mat[row][col] = ;
cal(row, col+); mat[row][col] = ;
cal(row, col+); mat[row][col] = ;
cal(row, col+);
}else{
cal(row, col+);
}
} int main(){
int t;
scanf("%d", &t);
int cnt = ;
while(t--){
scanf("%d%d%d%d", &A, &B, &C, &D);
memset(mat, , sizeof(mat));
ans = ;
cal(, );
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 ;
}

最新文章

  1. HDU 4946 Area of Mushroom(2014 Multi-University Training Contest 8)
  2. art.dialog 返回提示
  3. iNeedle日志下载功能问题
  4. 你用java的swing可以做出这么炫的mp3播放器吗?
  5. git的几十个基本面
  6. HDU 3333 Turing Tree --树状数组+离线处理
  7. Linux环境命令大全
  8. 敏捷BI——岂止于快
  9. shellinabox安装
  10. Jenkins初探
  11. CodeForces 706D Vasiliy&#39;s Multiset (字典树查询+贪心)
  12. 更新cydia“sub-process/usr/libexec/cydia/cydo returned anerror code(2)”是怎么回事?
  13. 【OpenMesh】使用网格的属性和特征
  14. ubuntu 16.04安装mips交叉编译
  15. pptpd免radius限速、限连接+自由定制功能脚本
  16. Linux 下执行本目录的可执行文件(命令)为什么需要在文件名前加“./”
  17. Ignatius and the Princess III HDU - 1028 -生成函数or完全背包计数
  18. 小程序 去掉 &lt;button /&gt; 组件默认 border 边框样式
  19. 线程的中断.interrupt
  20. FastDFS整合nginx后,nginx一直报错

热门文章

  1. 求数组前K个大的数
  2. Linux性能优化实战学习笔记:第三十四讲
  3. oracle 错误 TNS-01190与oracle 登入没反应操作
  4. There is no getter for property named &#39;id&#39; in &#39;class java.lang.Integer
  5. Python - 批量下载 IIS 共享的文件
  6. [转帖]k8s 中的服务如何沟通
  7. postgresql NUMERIC(precision, scale)
  8. 四种软件开发模式:tdd、bdd、atdd和ddd的概念
  9. 喜大普奔,又拍云全新产品 WebSocket 上线啦
  10. 元类理解与元类编程 《Python3网络爬虫开发》中第九章代理的使用代码Crawler中代码的理解