Link: L - World Cup

World Cup

pdf题面: 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.
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.
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.
• 1 ≤ T ≤ 100.
• 0 ≤ A, B, C, D ≤ 100.
Sample input
9 6 3 0
6 6 6 0
10 6 3 0
Sample Output
Case #1: Yes
Case #2: No
Case #3: Wrong Scoreboard
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
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.

Problem solving:
如果可以就输出Yes,如果多种胜负情况都会出现这种结果,就输出No,如果不会有任何一种情况导致这种结果的出现就输出Wrong Scoreboard。





#include <bits/stdc++.h>
using namespace std;
int score[4], T, jie[4];
struct node
    int a, b;
}                pk[6] = { 0, 1, 0, 2, 0, 3, 1, 2, 1, 3, 2, 3 };
map<string, int> ma;
void DFS(int n)
    if (n == 6)
        string mid;
        for (int i = 0; i < 4; i++)
            mid += score[i];
    for (int i = 0; i < 3; i++)
        int x = score[pk[n].a], y = score[pk[n].b];
        if (i == 0)
            score[pk[n].a] += 3;
        else if (i == 1)
            score[pk[n].b] += 3;
            score[pk[n].a] += 1, score[pk[n].b] += 1;
        DFS(n + 1);
        score[pk[n].a] = x; score[pk[n].b] = y;
int main()
    cin >> T;
    for (int k = 1; k <= T; k++)
        string mid;
        for (int i = 0; i < 4; i++)
            cin >> jie[i]; mid += jie[i];
        printf("Case #%d: ", k);
        if (ma[mid] == 0)
            puts("Wrong Scoreboard");
        else if (ma[mid] == 1)
    return 0;