The Best Subsequence
시간 제한2초메모리 제한2048 MB
긴 이진 문자열에 구간 뒤집기 갱신을 적용한 뒤, 각 질의마다 부분 문자열에서 사전순으로 가장 큰 길이 k 부분수열을 골라 그 값을 10^9+7로 나눈 나머지를 구한다.
문제
Farmer John has a binary string of length , initially all zeros.
He will first perform () updates on the string, in order. Each update flips every character from to . Specifically, flipping a character changes it from to , or vice versa.
Then, he asks you () queries. For each query, he asks you to output the lexicographically greatest subsequence of length comprised of characters from the substring from to . If your answer is a binary string , then output (that is, its value when interpreted as a binary number) modulo .
A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.
Recall that string is lexicographically greater than string of equal length if and only if at the first position , if it exists, where , we have .
입력
The first line contains , , and .
The next lines contain two integers, and () — the endpoints of each update.
The next lines contain three integers, , , and () — the endpoints of each query and the length of the subsequence.
출력
Output lines. The th line should contain the answer for the th query.