Prince of Mirzapur

All submissions for this problem are available.
Kaleen Bhaiya wants Munna to prove that he is capable enough to rule Mirzapur so he gave him a problem to solve but Munna is busy in college elections so he want you to help him and in return he will give you 50 eggs in college canteen. The problem is as follows: Given an array of size $N$ containing only 0 and 1 as elements. You are given $Q$ queries. Each query is of one of the two types.  $Type$ $0$: It contains two integers $0$ and $K$. For this type of query you have to print index of $K^{th}$ zero in array if it is present else print $1$.  $Type$ $1$: It contains three integers $1$ $L$ $P$. For this type of query you have to make A[L]=(fib(P)% 1000000007)%2. **Note:** fib(0)=0, fib(1)=1. Here fib(x) = $x^{th}$ Fibonacci number. ### Input  First line contains a single integer $N$ denoting the no of elements in the array.  The second line contains $N$ elements denoting $A[1]....A[N]$.  The third line contains a single integer $Q$ denoting the number of queries.  Then $Q$ lines follow, having any of the two queries mentioned above. **Note:** All the indices are 1based. ### Output Print the corresponding answer for the query of type 0 in a new line. ### Constraints  $1 \leq N, Q, K \leq 100000$  $0 \leq A_i \leq 1$  $1 \leq L \leq N$  $1 \leq P \leq 10$^{$18$} ### Example Input ``` 5 0 1 0 0 1 6 0 2 1 3 4 0 2 0 5 1 2 3 0 2 ``` ### Example Output ``` 3 4 1 2 ``` ### Explanation  For first query array is 0 1 0 0 1 and index of 2nd zero is 3.  For second query array becomes 0 1 1 0 1 as a[3] = fib(4)%2 = 3%2 = 1.  For third query array is 0 1 1 0 1 and index of 2nd zero is 4.  For fourth query array is 0 1 1 0 1 and there are less than 5 zeroes in the array so ans is 1.  For fifth query array becomes 0 0 1 0 1 as a[2] = fib(3)%2 = 2%2 = 0.  For third query array is 0 0 1 0 1 and index of 2nd zero is 2.Author:  abhist 
Tags  abhist 
Date Added:  31012019 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions