一、题目
二、代码
思路:
可以使用两个列表分别记录双方的胜、平、负次数
记录过程中也需要两个列表记录双方胜的手势
注意:
PAT 系统不准确,我测了几次,发现有时最后一个测试点超时,有时又可以完全通过,不知道几个意思
考试遇到这样情况没有思路修改的情况下,最后有时间可以多提交几次
num = int(input())
num1 = [0, 0, 0]
num2 = [0, 0, 0]
string1 = []
string2 = []
def test(s1,s2,string1,string2):
if s1 == 'C':
if s2 == 'J':
string1.append('C')
return True
else:
string2.append('B')
return False
elif s1 == 'J':
if s2 == 'B':
string1.append('J')
return True
else:
string2.append('C')
return False
elif s1 == 'B':
if s2 == 'C':
string1.append('B')
return True
else:
string2.append('J')
return False
def count(s):
if s.count('B') >= s.count('C'):
if s.count('B') >= s.count('J'):
return 'B'
else:
return 'J'
elif s.count('C') >= s.count('J'):
return 'C'
else:
return 'J'
for i in range(num):
A, B = input().split()
if A == B:
num1[1] += 1
num2[1] += 1
else:
if test(A, B,string1,string2):
num1[0] += 1
num2[2] += 1
else:
num1[2] += 1
num2[0] += 1
print("%d %d %d" % (num1[0], num1[1], num1[2]))
print("%d %d %d" % (num2[0], num2[1], num2[2]))
print("%c %c" % (count(string1),count(string2)))