groups take an interest in a season finisher competition. The competition comprises of 2k−1 games. They are held as follows: as a matter of first importance, the groups are parted into sets: group 1 plays against group 2, group 3 plays against group 4 (precisely in a specific order, etc (thus, 2k−1 games are
Correct answer will be upvoted else downvoted.
2k groups take an interest in a season finisher competition. The competition comprises of 2k−1 games. They are held as follows: as a matter of first importance, the groups are parted into sets: group 1 plays against group 2, group 3 plays against group 4 (precisely in a specific order, etc (thus, 2k−1 games are played in that stage). At the point when a group loses a game, it is wiped out, and each game outcomes in disposal of one group (there are no ties). From that point onward, just 2k−1 groups remain. If by some stroke of good luck one group remains, it is pronounced the hero; in any case, 2k−2 games are played: in the first of them, the champ of the game "1 versus 2" plays against the victor of the game "3 versus 4", then, at that point, the victor of the game "5 versus 6" plays against the champ of the game "7 versus 8, etc. This cycle rehashes until just one group remains.
Input :The principal line contains one integer k (1≤k≤18). The subsequent line contains a string comprising of 2k−1 characters — the underlying condition of the string s. Each character is either ?, 0, or 1. The third line contains one integer q (1≤q≤2⋅105) — the number of questions.
Then, at that point, q lines follow, the I-th line contains an integer p and a character c (1≤p≤2k−1; c is either ?, 0, or 1), depicting the I-th question.
Output :For each question, print one integer — f(s).
Step by step
Solved in 4 steps with 1 images