fork download
  1. # your code goes here
  2. import sys
  3. N = int(sys.stdin.readline())
  4. HISTORY, FLAG, FREEZE = None, False, False
  5. SCORE_BOARD = {'D':0, 'P':0}
  6. for _ in range(N):
  7. TEMP = str(sys.stdin.readline().rstrip())
  8. if(FREEZE == True):
  9. continue
  10. elif HISTORY == None:
  11. HISTORY = TEMP
  12. SCORE_BOARD[TEMP] += 1
  13. else:
  14. if(HISTORY == TEMP and not FLAG):
  15. FLAG = True
  16. SCORE_BOARD[TEMP] += 1
  17. elif(HISTORY == TEMP and FLAG):
  18. SCORE_BOARD[TEMP] += 1
  19. FREEZE = True
  20. else:
  21. FLAG = False
  22. HISTORY = TEMP
  23. SCORE_BOARD[TEMP] += 1
  24. print(str(SCORE_BOARD['D']) + ":" + str(SCORE_BOARD['P']))
Success #stdin #stdout 0.03s 9428KB
stdin
9
D
P
P
D
D
P
D
D
P
stdout
5:4