Logo
(追記) (追記ここまで)

34919번 - Marbles 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB13101076.923%

문제

Busy Beaver lines up $N$ marbles numbered 1ドル$ through $N,ドル where the $i$-th marble shows a number $p_i \neq i,ドル and every number from 1ドル$ to $N$ appears exactly once among $p_1, \dots, p_N$ (more formally, $p$ is a permutation over 1,ドル \dots, N$ such that $p_i \neq i$).

He wants to paint the marbles so that each marble $i$ has a different color from marble $p_i$. However, he only has three colors: red, green, and blue. Help him find any valid painting.

입력

The first line contains a single integer $T$ (1ドル \leq T \leq 10^4$) --- the number of test cases.

The first line of each test case contains one integer $N$ (2ドル \le N \le 10^5$) --- the number of marbles.

The second line of each test case contains $N$ integers $p_1, p_2, \dots, p_N$ (1ドル \le p_i \le N$; $p_i \ne i$) --- the numbers on the marbles. These numbers form a rearrangement of the numbers 1,ドル \dots, N$ in some order.

The sum of $N$ over all test cases does not exceed 10ドル^5$.

출력

For each test case, output a string of length $N$ containing the characters R, G, and B, where the $i$-th character denotes the color (red, green, or blue, respectively) of the $i$-th marble, satisfying the constraints.

If there are multiple possible answers, you can output any of them. We have a proof that under these constraints, an answer always exists.

제한

예제 입력 1

5
5
2 1 5 3 4
6
2 1 4 3 6 5
5
2 3 4 5 1
3
3 1 2
4
4 3 2 1

예제 출력 1

GBBGR
BGGRRB
RBRBG
RGB
BRGG

노트

In the first test case, the coloring GBBGR works as follows:

  • Marble 1ドル$ is colored green and has the number 2ドル$ written on it; marble 2ドル$ is colored blue, and since green is not blue, the constraint is satisfied.
  • Marble 2ドル$ is colored blue and has the number 1ドル$ written on it; marble 1ドル$ is colored green, and since blue is not green, the constraint is satisfied.
  • Marble 3ドル$ is colored blue and has the number 5ドル$ written on it; marble 5ドル$ is colored red, and since blue is not red, the constraint is satisfied.
  • Marble 4ドル$ is colored green and has the number 3ドル$ written on it; marble 3ドル$ is colored blue, and since green is not blue, the constraint is satisfied.
  • Marble 5ドル$ is colored red and has the number 4ドル$ written on it; marble 4ドル$ is colored green, and since red is not green, the constraint is satisfied.

출처

University > MIT > M(IT)^2 > M(IT)^2 Winter 2025-26 Tournament > Beginner Round 3번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /