Hoof, Paper, Scissors【USACO 2017 January Contest, Bronze】


You have probably heard of the game "Rock, Paper, Scissors". The cows like to play a similar game they call "Hoof, Paper, Scissors".

The rules of "Hoof, Paper, Scissors" are simple. Two cows play against each-other. They both count to three and then each simultaneously makes a gesture that represents either a hoof, a piece of paper, or a pair of scissors. Hoof beats scissors (since a hoof can smash a pair of scissors), scissors beats paper (since scissors can cut paper), and paper beats hoof (since the hoof can get a papercut). For example, if the first cow makes a "hoof" gesture and the second a "paper" gesture, then the second cow wins. Of course, it is also possible to tie, if both cows make the same gesture.

Farmer John watches in fascination as two of his cows play a series of N games of "Hoof, Paper, Scissors" (1≤N≤100). Unfortunately, while he can see that the cows are making three distinct types of gestures, he can't tell which one represents "hoof", which one represents "paper" and which one represents "scissors" (to Farmer John's untrained eye, they all seem to be variations on "hoof"...)

Not knowing the meaning of the three gestures, Farmer John assigns them numbers 1, 2, and 3. Perhaps gesture 1 stands for "hoof", or maybe it stands for "paper"; the meaning is not clear to him. Given the gestures made by both cows over all N games, please help Farmer John determine the maximum possible number of games the first cow could have possibly won, given an appropriate mapping between numbers and their respective gestures.



农夫约翰着迷地看着他的两只母牛玩一系列的“蹄子、布、剪刀”游戏(1)≤N≤100). 不幸的是,虽然他能看到奶牛在做三种不同类型的手势,但他不知道哪一种代表“蹄”,哪一种代表“纸”,哪一种代表“剪刀”(在农夫约翰未经训练的眼里,它们似乎都是“蹄”的变体……)


输入格式(Format Input)

The first line of the input file contains N.
Each of the remaining N lines contain two integers (each 1, 2, or 3), describing a game from Farmer John's perspective.
输出格式(Format Output)
Print the maximum number of games the first of the two cows could possibly have won.

输入样例(Sample Input)

1 2
2 2
1 3
1 1
3 2

输出样例(Sample Output)



One solution (of several) for this sample case is to have 1 represent "scissors", 2 represent "hoof", and 3 represent "paper". This assignment gives 2 victories to the first cow ("1 3" and "3 2"). No other assignment leads to more victories.
对于这个示例案例,一种解决方案是1代表“剪刀”,2代表“蹄子”,3代表“纸”。这项任务给第一头牛两次胜利(“1 3”和“3 2”)。没有其他任务能带来更多的胜利。

using namespace std;
int n,ans1,ans2;
int fir[1001],sec[1001];
int main()
    for(int i=1;i<=n;i++)
    for(int i=1;i<=n;i++)
    return 0;