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

C. Another Wine Tasting Event

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

After the first successful edition, Gabriella has been asked to organize a second wine tasting event. There will be 2\(n - 1\) bottles of wine arranged in a row, each of which is either red wine or white wine. This time, Gabriella has already chosen the type and order of all the bottles. The types of the wines are represented by a string \(s\) of length 2\(n - 1\). For each \(1 \le i \le 2n - 1\), it holds that \(s_{i} = R\) if the \(i-th\) bottle is red wine, and \(s_{i} = W\) if the \(i-th\) bottle is white wine. Exactly \(n\) critics have been invited to attend. The critics are numbered from 1 to \(n\). Just like last year, each critic \(j\) wants to taste an interval of wines, that is, the bottles at positions \(a_{j}\), \(a_{j}+1\), . . . , \(b_{j}\) for some \(1 \le a_{j} \le b_{j} \le 2n - 1\). Moreover, they have the following additional requirements: • each of them wants to taste at least \(n\) wines, that is, it must hold that \(b_{j} - a_{j} + 1 \ge n\); • no two critics must taste exactly the same wines, that is, if \(j\)̸ = \(k\) it must hold that \(a_{j}\)̸ = \(a_{k}\) or \(b_{j}\)̸ = \(b_{k}\). Gabriella knows that, since the event is held in a coastal region of Italy, critics are especially interested in the white wines, and don’t care much about the red ones. (Indeed, white wine is perfect to accompany seafood.) Thus, to ensure fairness, she would like that all critics taste the same number of white wines. Help Gabriella find an integer \(x\) (with \(0 \le x \le 2n - 1\)) such that there exists a valid assignment of intervals to critics where each critic tastes exactly \(x\) white wines. It can be proved that at least one such \(x\) always exists.

제약
입력 형식

The first line contains the integer \(n\) (\(1 \le n \le 10^{6}\)) — where 2\(n - 1\) is the number of bottles, and \(n\) is the number of critics. The second line contains a string \(s\) of length 2\(n - 1\) that represents the arrangement of the wines — the \(i-th\) character of \(s\) (\(1 \le i \le 2n - 1\)) is R for a red wine and W for a white wine.

출력 형식

Print an integer \(x\) — the number of white wines that each critic will taste. It can be proved that at least one solution exists. If multiple solutions exist, any of them will be accepted. Problem C: Another Wine Tasting Event SWERC \(2022-2023\)

예제 1
입력
5
RWWRRRWWW
출력
2
예제 2
입력
1
R
출력
0
문제 정보

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

출처 ICPC SWERC 2022

평가 및 의견

C. Another Wine Tasting Event

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

Log in to rate problems.

개별 의견

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

풀이 제출

C. Another Wine Tasting Event

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