아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Brperm

시간 제한2초메모리 제한1024 MB

요약
색 문자열과 길이 2^k 블록에 대한 비트 반전 순열이 주어질 때, i에서 시작하는 블록이 그 순열에 의해 변하지 않는지 묻는 질의에 답한다.
난이도

보통10점 중 6점

유형
문자열 매칭, 비트 연산, 해시맵
정답자
아직 제출이 없습니다

문제

Note: in the following statement, b_1…b_k‾\overline{b\_1 \dots b\_k} represents an integer written out in binary notation, where b_1b\_1 is the most significant bit, and b_kb\_k is the least significant bit.

Roxanne the space witch, while riding her broomstick throughout the galaxy, came across a planet in which everybody danced a strange dance: planet Br-perm. In this dance, the participants stand in a line, and then reorder themselves. Suppose 2k2^k people are dancing. Then, the person at position b_1…b_k‾\overline{b\_1 \dots b\_k} goes to position b_1…b_k‾\overline{b\_1 \dots b\_k} (indexed from 00).

Roxanne noticed also that every person on Br-perm wears one of 2626 colors of clothing. These colors are represented by the letters of the Latin alphabet.

The Br-perm-ians place special significance on rows of dancers where the sequence of colors of clothing that people are wearing before and after the dance are the same. They call such sequences nice. For instance, when k=2k = 2, we have a row of four dancers 0,1,2,30, 1, 2, 3, that after the dance become ordered like so: 0,2,1,30, 2, 1, 3. So, the sequence of clothing colors abba is nice, but abca is not.

The Br-perm-ians have asked Roxanne to help them with a difficult matter (space witches always seem to have to help people with their problems). They show her a long row of nn dancers, and ask her several questions: “is the sequence of length 2k2^k starting at dancer ii nice?”

제한

  • 1≤N≤500,0001 ≤ N ≤ 500\\,000
  • 1≤Q≤500,0001 ≤ Q ≤ 500\\,000

예제1

  1. 예제 1

    입력
    init(8, "axxyxxyb")
    
    예상 출력
    query(0, 3) = true
    query(1, 1) = true
    query(0, 2) = false
    query(3, 2) = true