RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
R03622

J3. Creative Candy Consumption

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Ngoc and Minh devised a creative way to eat candy that comes in three
different colours: red, green, and blue.

They begin by arranging some coloured candies into a line. Then, the
candy at the front of Ngoc's line is compared to the candy at the front
of Minh's line. If both candies are the same colour, then Ngoc and Minh
each eat the candy at the front of their own line. If the candies are
different colours, then the person with the winning candy eats the
losing candy, and the winning candy stays at the front of its line.

  • Red candy

wins against green candy

.

  • Green candy

wins against blue candy

.

  • Blue candy

wins against red candy

.

This process of comparing and eating candy repeats until there is at
least one empty line of candy. When that happens, if one person still
has candy left in their line, then that person eats all of their
leftover candy.

Your job is to determine how much candy each person eats.

제약
입력 형식

The first line of input contains a sequence of \(N\) letters, representing Ngoc's line of
candy. The second line of input contains a sequence of \(M\) letters, representing Minh's line of
candy. Each letter will be an uppercase R, G,
or B representing the colours red, green, and blue,
respectively. The first letter in each sequence represents the colour of
the candy at the front of that person's line. (There will always be at
least one letter in each sequence.)

출력 형식

There will be two lines of output.

On the first line, output the number of candies Ngoc eats. On the
second line, output the number of candies Minh eats.

서브태스크
서브태스크점수설명

1

13점

Ngoc and Minh each have one candy. — \(N = 1\) and \(M = 1\)

2

27점

Either Ngoc's line will empty first, or both lines will empty at the same time. Ngoc and Minh could have many candies. — \(N \leq 50\) and \(M \leq 50\)

3

47점

Ngoc and Minh could have many candies. — \(N \leq 50\) and \(M \leq 50\)

4

13점

Ngoc and Minh could have an absurd amount of candy. — \(N \leq 1\,000\,000\) and \(M \leq 1\,000\,000\)

예제 1
입력
RRR
RGBB
출력
2
5
설명
Candy Lines Description Summary
Ngoc: Minh: Both people have red candy at the front of their lines. Ngoc eats her red candy and Minh eats his red candy. So far, Ngoc has eaten (1) candy and Minh has eaten (1) candy.
Ngoc: Minh: Ngoc's red candy wins against Minh's green candy. Ngoc eats Minh's green candy. So far, Ngoc has eaten (2) candies and Minh has eaten (1) candy.
Ngoc: Minh: Minh's blue candy wins against Ngoc's red candy. Minh eats Ngoc's red candy. So far, Ngoc has eaten (2) candies and Minh has eaten (2) candies.
Ngoc: Minh: Minh's blue candy wins against Ngoc's red candy. Minh eats Ngoc's red candy. So far, Ngoc has eaten (2) candies and Minh has eaten (3) candies.
Ngoc: Minh: Ngoc's line of candy is empty, so the process ends. Minh eats his remaining blue candies. In total, Ngoc eats (2) candies and Minh eats (5) candies.
문제 정보

생성자가 기록되지 않았습니다.

출처 CCC 2026 Junior

평가 및 의견

J3. Creative Candy Consumption

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

J3. Creative Candy Consumption

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8