Färgrobot | 프로그래밍의 벗 PivotOJ
PivotOJ

Färgrobot

시간 제한: 1000ms메모리 제한: 1024MB출처: Programmeringsolympiaden 2016 — onlinekvalBOJ 21287
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

A robot can move along a row of colored squares. Every square can be either red, green or blue. A command to the robot is a color. The robot responds by moving to the right until it stands on the color specified by the command. Write a program that, for a given sequence of squares and a number NN, writes out the sequence of NN commands that makes the robot go as far to the right as possible.

[이미지 1]

Figure 1: An illustration of the third sample case.

입력

The first line containes an integer NN, the number of commands to give to the robot. The second line contains a string of letters, R , G, or B, which specifies the color of each square in the row, from left to right. The string contains less than 200 characters, and is always sufficiently long that no sequence of NN commands may cause the robot to reach outside the row of squares.

출력

The program should output a string of NN characters, each being R, G, or B, which constitutes the sequence of commands you should give to the robot to make it move as far as possible along the row of squares. If there are several sequences that accomplish this, you may output anyone of them.

예제

예제 1

입력
1
RRBBBGG
출력
G

예제 2

입력
2
GBBRGRGBRG
출력
RB

예제 3

입력
3
RGBGRRBGBBRG
출력
BBR

예제 4

입력
4
RBRBRBBRBRBRGRGGRGGGRBBRBRRBBRBRBRGBGBGBBGBGBGBBBGBGR
출력
GBGR
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.