https://www.acmicpc.net/problem/16675
ms1,ms2,tk1,tk2 = ('SPR'.index(i) for i in input().split())
check = False
if ms1 == ms2 :
if ms1 == 0:
if 2 in (tk1,tk2):
check = True
print("TK")
else:
if (ms1-1) in (tk1,tk2):
check = True
print("TK")
if tk1 == tk2:
if tk1 == 0:
if 2 in (ms1,ms2):
check = True
print("MS")
else:
if(tk1-1) in (ms1,ms2):
check = True
print("MS")
if check == False:
print("?")
ms1,ms2,tk1,tk2 = ('SPR'.index(i) for i in input().split())
if ms1 == ms2 and (ms1+2)%3 in (tk1,tk2):
print("TK")
elif tk1 == tk2 and (tk1+2)%3 in (ms1,ms2):
print("MS")
else:
print('?')
요런식으로 받을수 있다는것 처음 써본것같다.
('ABC'.index('A'))
하면 0 나온다.
요런식으로 문자열 두개 튜플로 넣어서 그안에 특정값이 들어있는지 검색 가능하다.
처음에는 tk1, tk2를 배열에 넣어서 배열안에 2가 있는지 찾아봐야겠다 생각했는데
구지 배열만들어서 append 하지 않아도 튜플식으로 k in (a,b) 요렇게 바로 비교가능하다.
다른풀이의 경우는 모듈러 연산 이용해서 코드량을 줄인 풀이인데
돌려보니 실행속도 자체는 똑같다
모듈러도 요럴때 활용하면 잘 써먹을수 있을것같다.
끝!.