题目链接:

http://codeforces.com/gym/101194/attachments

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5930

题意:

现有四支队伍两两打比赛,总共就是打六场比赛,每场比赛赢的队伍可得 $3$ 分,输的队伍得 $0$ 分,平局则两个队各得 $1$ 分。

现在给出四个队伍最终的积分,问能否确切给出每场比赛的结果。

题解:

显然,六场比赛,每场有三种结果,三进制数 $[0,3^6)$  暴力枚举所有可能的六场比赛结果即可。

AC代码:

#include<bits/stdc++.h>
using namespace std;
const int MAX=(int)pow(,);
const int t1[]={,,,,,};
const int t2[]={,,,,,};
int a,b,c,d;
int score[MAX][];
inline bool Same(int s) {
return score[s][]==a&&score[s][]==b&&score[s][]==c&&score[s][]==d;
}
void Solve()
{
memset(score,,sizeof(score));
for(int sta=;sta<MAX;sta++)
{
for(int i=,s=sta;i<;i++,s/=)
{
int res=s%;
switch(res)
{
case :
score[sta][t1[i]]+=;
break;
case :
score[sta][t2[i]]+=;
break;
case :
score[sta][t1[i]]++;
score[sta][t2[i]]++;
break;
}
}
}
int tot=;
for(int sta=;sta<MAX;sta++) if(Same(sta)) tot++;
if(!tot) printf("Wrong Scoreboard\n");
else if(tot==) printf("Yes\n");
else printf("No\n");
}
int main()
{
int T;
cin>>T;
for(int kase=;kase<=T;kase++)
{
cin>>a>>b>>c>>d;
printf("Case #%d: ",kase);
Solve();
}
}
05-04 07:23