#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int T;
cin>>T;
while(T--){
int x,y;
string a,b;
cin>>a>>b;
if(a=="Hunter")x=0;
else if(a=="Bear")x=1;
else x=2;
if(b=="Hunter")y=0;
else if(b=="Bear")y=1;
else y=2;
if(x==y)puts("Tie");
else if(x==(y+1)%3)puts("Player1");
else puts("Player2");
}
return 0;
}
这里的难点在于循环相克,但是仔细观察发现,按照HBG
的顺序来写
H0H
B1B
G2G
B1>H0
G2>B1
H0>G2(这里下面会提到)
按照这样的循环规律,后面的数会大于前面的
也就是else if(x==(y+1)%3)puts(“Player1”);的写法
当y=0时,也就是猎人,(0+1)%3得1,也就是1,1也就代表了x,熊,所以x熊赢了
以此类推当y=2,枪,x=0猎人,这也就是为什么要取余的原因。这样便构成了循环相克