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

F. Bottle Arrangements

스페셜 저지 — 출력을 사용자 정의 프로그램으로 검사하므로 여러 정답이 인정될 수 있습니다.
설명

Gabriella has been instructed to organize a renowned wine tasting event which will be attended by \(m\) critics. On display, there will be \(n\) different varieties of wine, each of which can either be a red wine or a white wine. The wines will come in \(n\) bottles arranged in a line on the table, and, for convenience, each critic will sip from a contiguous interval of bottles: that is, \(he/sh\)e will taste exactly the bottles at position a, \(a + 1\), . . . , \(b\) for some \(1 \le a \le b \le n\). The interval depends on the critic, who will select it on the spot according to their preferences. In fact, the \(i-th\) critic (\(1 \le i \le m\)) has requested that \(he/sh\)e wants to taste exactly \(r_{i}\) red wines and \(w_{i}\) white wines. Gabriella has yet to choose how many bottles of red wine and white wine there will be, and in what order they will appear. Help her find an arrangement (that is, a sequence of \(n\) bottles of either red or white wine) that satisfies the requests of all the critics, or state that no such arrangement exists.

제약
입력 형식

Each test contains multiple test cases. The first line contains an integer \(t\) (\(1 \le t \le 100\)) — the number of test cases. The descriptions of the \(t\) test cases follow. The first line of each test case contains two integers \(n\) and \(m\) (\(1 \le n \le 100\), \(1 \le m \le 100\)) — the number of bottles of wine and the number of critics. Each of the next \(m\) lines contains two integers \(r_{i}\) and \(w_{i}\) (\(0 \le r_{i}\), \(w_{i} \le 100\), \(r_{i} + w_{i} \ge 1\)) — the number of red and white wines that the \(i-th\) critic wants to taste.

출력 형식

For each test case, if at least one solution exists, print a string of length \(n\) made up of the characters R and W, where the \(j-th\) character (\(1 \le j \le n\)) denotes the type of the wine in the \(j-th\) bottle of the arrangement (R for red and W for white). If there are multiple solutions, print any. If no solution exists, print the string IMPOSSIBLE. Problem F: Bottle Arrangements SWERC \(2021-2022\)

예제 1
입력
3
5 3
1 0
3 2
2 2
4 3
2 1
1 1
0 3
3 2
0 2
0 3
출력
RRRWW
IMPOSSIBLE
WWW
문제 정보

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

출처 ICPC SWERC 2021

평가 및 의견

F. Bottle Arrangements

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

Log in to rate problems.

개별 의견

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

풀이 제출

F. Bottle Arrangements

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