JiaoZhu and SC
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 1135(395 users) Total Accepted: 466(360 users) Rating: Special Judge: No
Description
自从电子竞技在中国被认定为第99个正式体育项目,教主就投身其中,SC(StarCraft 星际争霸)他拿手的一款游戏,当然也有很多职业选手参与其中。
星际争霸中有3个种族:T(人族),P(神族),Z(虫族)而且每个玩家必须选择且只能选择一个种族来使用。
在职业电子竞技联赛中,每位职业选手都会固定使用某一个自己喜爱的种族。
在经过大量的比赛后,发现有如下的规律:
1.使用人族的选手总是能战胜虫族选手
2.使用虫族的选手总是能战胜神族选手
3.使用神族的选手总是能战胜人族选手
4.使用相同种族的选手对战总是产生平局
现在将告诉你每个选手的种族,并进行若干场比赛,要求你输出每场比赛的结果。
Input
本题只有一组测试数据
第一行:N M (1 <= N, M<= 10000),N代表选手的数目,M代表比赛的场数。
接下来N行,每行首先给出选手名字(玩家的名字只由大写、小写字母、数字组成,其中没有空格,最长的名字占10个字符)接着是他的种族(用T、P、Z表示)
接下来M行,每行代表一场比赛,首先给出选手A的名字,接着给出选手B的名字。
Output
对于每场比赛:
选手A胜利 输出”XiaoM Wins!”
选手B胜利 输出”TianT Wins!”
平局 输出”End in a draw!”
Sample Input
4 4
JiaoZhu T
Jaedong Z
Chadalt T
LMJ Z
JiaoZhu Chadalt
Jaedong LMJ
JiaoZhu LMJ
LMJ Chadalt
Sample Output
End in a draw!
End in a draw!
XiaoM Wins!
TianT Wins!
Hint
输入量巨大,建议使用scanf()与printf(),使用cin与cout可能会超时
Author
Chadalt
题解
使用STL中的map建立对应关系,由对应关系去寻找是否可以战胜。
代码如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using namespace std ;
int main(){
int n , m ;
while ( cin >> n >> m ){
map<string , char> map_ ;
for ( int i = 0 ; i < n ; i ++ ){
string str1 ;
char str2 ;
cin >> str1 >> str2 ;
map_.insert(make_pair(str1 , str2)) ;
}
for ( int i = 0 ; i < m ; i ++ ){
string str1 , str2 ;
cin >> str1 >> str2 ;
map<string , char>::iterator it1 = map_.find(str1) ;
map<string , char>::iterator it2 = map_.find(str2) ;
if ( it1->second == it2->second ){
// cout << "End in a draw!" << endl ;
printf("End in a draw!\n") ;
}else if ( (it1->second == 'T' && it2->second == 'Z')
|| (it1->second == 'Z' && it2->second == 'P')
|| (it1->second == 'P' && it2->second == 'T')){
// cout << "XiaoM Wins!" << endl ;
printf("XiaoM Wins!\n") ;
}else{
// cout << "TianT Wins!" << endl ;
printf("TianT Wins!\n") ;
}
}
}
return 0 ;
}
//T>Z>P>T