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

18929번 - Knights of Round Table 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB170877047.619%

문제

2ドルN$ knights sit around a round table, they are numbered by King Arthur in clockwise order with integers from 1 to 2ドルN$. Knight $j$ is a neighbor of knights $j - 1$ and $j + 1,ドル knights 1 and 2ドルN$ are neighbors too. The knights represent $N$ orders, each order is represented by exactly two knights and each knight represents exactly one order.

There are two types of magical potion today prepared by Merlin. Let's call them X and Y. Merlin wants to distribute drinks between the knights satisfying the following conditions:

  • Each knight will drink exactly one of the potions, X or Y.
  • Knights from the same order must drink different potions.
  • No three consecutive knights at the table drink the same potion.

Find any distribution which conforms with Merlin's requirements or determine that no such distribution exists

입력

The first line contains a single integer $N$ (2ドル \le N \le 5 \cdot 10^5$) --- the number of orders represented at the table. Each of the next $N$ lines describes one order and contains two integers $a$ and $b$ (1ドル \le a, b \le 2N$), denoting the numbers of knights of that order at the table. All numbers in those $N$ lines are pairwise distinct.

출력

If there is no solution, print a single word "impossible".

Otherwise, print a single string with 2ドルN$ characters 'X' and 'Y' describing the distribution of potions. The $i$-th character must represent the selection for knight $i$.

If there is more than one possible distribution, print any of them.

제한

예제 입력 1

4
1 5
2 3
6 7
4 8

예제 출력 1

XYXYYXYX

힌트

출처

Camp > Bytedance-Moscow Workshops Camp > Bytedance-Moscow Workshops Camp 2020 > Contest 1 K번

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

출처

대학교 대회

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

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