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

32367번 - Painting Roads 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB766100.000%

문제

Alanna, the mayor of Kitchener, has successfully improved the city’s road plan. However, a traveling salesperson from the city of RedBlue complained that the roads are not colourful enough. Alanna’s second job is to paint some of the roads.

Kitchener’s road plan can be represented as a collection of N intersections with M roads, where the i-th road connects intersections ui and vi. All roads are initially grey. Alanna would like to paint some of the roads in red or blue such that the following condition is satisfied:

  • Whenever there is a grey road that connects ui and vi, there is also a path of roads from ui to vi such that the roads on the path alternate between red and blue, without any of the roads on this path being grey.

To lower the city’s annual spending, Alanna would like to minimize the number of painted roads. Can you help Alanna design a plan that meets all the requirements?

입력

The first line contains two integers N and M (1 ≤ N, M ≤ 2 · 105).

The i-th of the next M lines contains two integers ui and vi, meaning that there exists a road from intersection ui to intersection vi (1 ≤ ui, vi ≤ N, ui ≠ vi).

There is at most one road between any unordered pair of intersections.

출력

Output a string of M characters, representing the paint plan. The i-th character should be R if the i-th road is to be painted red, B if i-th road is to be painted blue, or G (for “grey”) if the i-th road is to be left unpainted.

Remember that you must minimize the number of painted roads while satisfying the condition. If there are multiple possible such plans, output any of them.

제한

서브태스크

Subtask Score Additional Constraints
1 2 There is a road connecting intersection i with intersection i + 1 for all 1 ≤ i < N (and possibly other roads).
2 3 We can reach any intersection from any other intersection, and N = M.
3 3 No road belongs to two or more simple cycles (see Definition below).
4 7 None

Definition: if we denote a road between intersections u and v as u ↔ v, then a simple cycle is a sequence w1 ↔ w2 ↔ . . . ↔ wk ↔ w1 where k ≥ 3 and all wi are distinct.

예제 입력 1

5 7
1 2
2 4
5 2
4 5
4 3
1 3
1 4

예제 출력 1

RGGRGRB

A diagram of the intersections along with a valid paint plan that minimizes the number of painted roads is shown below. Note that the colours are shown on each road as R (red), B (blue), or G (grey).

All the unpainted roads satisfy the condition:

  • The 2nd road, labelled G2, connects intersection 2 with intersection 4. The path through intersections 2, 1, 4 alternates red, blue.
  • The 3rd road, labelled G3, connects intersection 5 with intersection 2. The path through intersections 5, 4, 1, 2 alternates red, blue, red.
  • The 5th road, labelled G5, connects intersection 4 with intersection 3. The path through intersections 4, 1, 3 alternates blue, red.

예제 입력 2

4 2
1 2
3 4

예제 출력 2

BB

Note that it is possible for Kitchener to be disconnected.

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2024 > CCC 2024 Senior Division 4번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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