루미 알고리즘

#1631브론즈Truls' Troubles

PO 2025 학교 예선코딩출제 Harry Zhang영어 원문이 문제가 어렵다면 — 배우는 순서 보기

영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)

Problem

Truls and Henry are playing table tennis against each other.

Both Truls and Henry strongly dislike math. More than anything, they hate calculating how many points each of them has during the game. To simplify scoring, they have come up with their own solution:

Instead of constantly keeping track of their points, they write a “T” if Truls scores a point and an “H” if Henry scores a point, immediately after each won rally.

When Truls and Henry play table tennis, the scoring system works according to these three rules:

1) One point is awarded after each rally.

2) A player wins a match if both of the following conditions are met:

  • The player leads by at least 2 points over their opponent.
  • The player has at least 11 points.

For example, if Truls has 11 points and Henry has 9 points, Truls is declared the winner. But if Truls has 11 points and Henry has 10 points, there is no winner yet.

3) When a player wins according to the criteria above, the points for both players are reset to zero, and a new match begins.

Now Truls and Henry have been playing for a long time, and both want to know the current score. They ask you to write a program that calculates the current score for them based on their notes.

Input

Input consists of Truls and Henry's notes, which consists of multiple letters on a single line. The number of letters is between 1 and 30. Each letter will be either “T” or “H”.

Output

Print the score of the ongoing match as T-H, where T is the number of points Truls has, and H is the number of points Henry has.

Scoring

Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.

GroupPointsConstraints
140A match always ends as soon as one player reaches 11 points.
260No additional constraints.

Explanation of Sample 1

In total, Truls has won 4 points, and Henry has won 5 points.

Explanation of Sample 2

Since Truls won the match when the score reached 11-0, the score was reset to 0-0.

Explanation of Sample 3

Even though both have more than 11 points, neither leads by 2 points. Therefore, no winner has been declared yet.

Explanation of Sample 4

This game is a continuation of sample 3, where Henry wins the match after scoring two more points. The score is reset, and Henry then wins another point. Therefore, the score is 0-1.

예제

예제 1

입력
TTTHHHTHH
출력
4-5

예제 2

입력
TTTTTTTTTTT
출력
0-0

예제 3

입력
THTHTHTHTHTHTHTHTHTHTHTH
출력
12-12

예제 4

입력
THTHTHTHTHTHTHTHTHTHTHTHHHH
출력
0-1

출처 표기

출처: Programmeringsolympiaden 2025년 학교 예선 · 원문 페이지 · 이용 조건 CC BY-SA · LaTeX 원문을 화면용 글로 옮겼습니다(수식·표의 모양이 다를 수 있습니다). 내용은 고치지 않았습니다.

크리에이티브 커먼즈 저작자표시-동일조건변경허락.

문제 출처: 한국정보올림피아드(KOI) (CC BY-NC-SA 4.0) · International Olympiad in Informatics (IOI) (CC BY) · Centre for Education in Mathematics and Computing (CEMC), University of Waterloo (CC BY-NC 4.0) · Programmeringsolympiaden (CC BY-SA) · CSES Problem Set (Antti Laaksonen) (CC BY-NC-SA 4.0). 루미 알고리즘은 위 단체들과 관계없는 별도의 서비스이며, 자료는 원문 그대로 싣습니다. 문제마다 출처와 이용 조건을 따로 표기합니다.