CF1076G.Array Game

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Consider a following game between two players:

There is an array b1b_1 , b2b_2 , ..., bkb_k , consisting of positive integers. Initially a chip is placed into the first cell of the array, and b1b_1 is decreased by 11 . Players move in turns. Each turn the current player has to do the following: if the index of the cell where the chip is currently placed is xx , then he or she has to choose an index y[x,min(k,x+m)]y \in [x, min(k, x + m)] such that by>0b_y > 0 , move the chip to the cell yy and decrease byb_y by 11 . If it's impossible to make a valid move, the current player loses the game.

Your task is the following: you are given an array aa consisting of nn positive integers, and qq queries to it. There are two types of queries:

  • 11 ll rr dd — for every i[l,r]i \in [l, r] increase aia_i by dd ;
  • 22 ll rr — tell who is the winner of the game that is played on the subarray of aa from index ll to index rr inclusive. Assume both players choose an optimal strategy.

输入格式

The first line contains three integers nn , mm and qq ( 1n,q21051 \le n, q \le 2 \cdot 10^5 , 1m51 \le m \le 5 ) — the number of elements in aa , the parameter described in the game and the number of queries, respectively.

The second line contains nn integers a1a_1 , a2a_2 , ..., ana_n ( 1ai10121 \le a_i \le 10^{12} ) — the elements of array aa .

Then qq lines follow, each containing a query. There are two types of queries. The query of the first type is denoted by a line 11 ll rr dd ( 1lrn1 \le l \le r \le n , 1d10121 \le d \le 10^{12} ) and means that for every i[l,r]i \in [l, r] you should increase aia_i by dd . The query of the second type is denoted by a line 22 ll rr ( 1lrn1 \le l \le r \le n ) and means that you have to determine who will win the game if it is played on the subarray of aa from index ll to index rr (inclusive).

There is at least one query of type 22 .

输出格式

For each query of type 22 print 11 if the first player wins in the corresponding game, or 22 if the second player wins.

输入输出样例

  • 输入#1

    5 2 4
    1 2 3 4 5
    1 3 5 6
    2 2 5
    1 1 2 3
    2 1 5
    

    输出#1

    1
    1
    
  • 输入#2

    5 1 3
    1 1 3 3 4
    2 1 5
    2 2 5
    2 3 5
    

    输出#2

    1
    2
    1
    
首页