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

Ljepotica

Unrated 레이팅 미적용
난이도
0.500s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Croatian Olympiad in Informatics 2019.

Page 4 of 9

Beauty and the Geek is a reality television series advertised as connecting female beauties and male geeks
with the goal of creating "The Ultimate Social Experiment". This task is advertised as connecting reality
TV and competitive programming with the goal of creating a fun task.
Our hero is a beauty Ena, trapped in a complete binary tree of depth N. Each node of the tree has a
value: root of the tree has a value of 1, and for each node with a value of \(x\), its left child has a value of
2x, and its right child has a value of 2\(x + 1\). Ena can move from a node to one of its two children,
heading for the exit which is located in one of the leaves (nodes of depth N, with no children).
Ena knows an exact path from the root to the exit leaf. More precisely, she knows the correct sequence
of N – 1 moves, each of them being “left“ or “right“, which would guide her from the root to the exit
leaf. Unfortunately, Ena is not sure which side is left and which side is right. Therefore, during her trip,
she changed her mind exactly K times about the meaning of “left” and “right”. When she changes her
mind, she moves accordingly until the end of the trip (a leaf node) or until the next change of mind.
Ena's change of mind can happen only once before each move in the tree (including the first one).
Also, nobody knows whether Ena had correct sides in mind while entering the root of the tree.
The producers of the TV show will save the lost Ena if you, her geek partner, answer correctly to the
following question: What is the sum of leaf values where Ena can finish her trip, considering only leaves
with values of at least A and at most B?

제약

subtask
points
additional constraints
1
8
\(K = 0\)
2
14
\(N \le 25\)
3
17
A is the smallest, and B is the greatest value
where Ena can finish
4
61
no additional constraints

(See examples on the next page.)

Croatian Olympiad in Informatics 2019.

Page 5 of 9

입력 형식

The first line contains integers N and K from the task description (\(2 \le N \le 1000\), \(0 \le K \le N\) – 1).
In the second line there is a word containing N – 1 characters ‘L’ (left) and ‘R’ (right) representing the
correct path from the root to the exit leaf.
The third line contains the number A from the task description, in binary form without leading zeros.
The fourth line contains the number B from the task description, in binary form without leading zeros.
Ena will be able to finish in leaves A and B.

출력 형식

Output the required sum as a decimal integer modulo 1 000 000 007.

예제 1
입력
3 0
LR
101
110
출력
11
예제 2
입력
4 2
LRR
1010
1110
출력
37
예제 3
입력
5 2
RLLR
10010
10111
출력
82

First sample description: Ena will never change her mind, but we don't known if she had the correct
left/right sides in mind from the beginning. So, she might have followed the instructions correctly and
go to the left, and then the right child. Or, she might have followed the inverse instructions, going first
to the right child and then to the left child. The arriving leaves have values 5 and 6 which correspond to
A and B, so the answer is 5 + 6.
Second sample description: Possible Ena's paths: (left, left, left), (left, left, right), (left, right, left),
(right, left, right), (right, right, left), or (right, right, right).
문제 정보

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

출처 COCI 2018/2019 Olympiad

평가 및 의견

Ljepotica

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

Log in to rate problems.

개별 의견

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

풀이 제출

Ljepotica

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