CF1076G.Array Game

NOI/NOI+/CTSC

通过率:0%

时间限制:6.00s

内存限制:512MB

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 \gt 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.

考虑以下两个玩家之间的游戏:

给定一个由正整数构成的数组 b1b_1, b2b_2, ..., bkb_k。初始时,一枚棋子被放置在该数组的第一个单元格(即索引为 11 的位置),且 b1b_1 的值减 11。两名玩家轮流进行操作。在每一轮中,当前玩家必须执行以下操作:若棋子当前位于索引为 xx 的单元格,则他/她必须选择一个索引 y∈[x,min⁡(k,x+m)]y \in [x, \min(k, x + m)],使得 by>0b_y > 0,然后将棋子移动至单元格 yy,并将 byb_y 的值减 11。若无法进行任何合法移动,则当前玩家输掉游戏。

你的任务如下:你将得到一个由 nn 个正整数组成的数组 aa,以及对该数组的 qq 个查询。查询分为两类:

  • 11 ll rr dd — 对每个 i∈[l,r]i \in [l, r],将 aia_i 增加 dd;
  • 22 ll rr — 判断在数组 aa 的子数组 al,al+1,…,ara_l, a_{l+1}, \dots, a_r 上进行上述游戏时,哪位玩家获胜(假设双方均采用最优策略)。

输入格式

The first line contains three integers nn, mm and qq (1≤n,q≤2⋅1051 \le n, q \le 2 \cdot 10^5, 1≤m≤51 \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 (1≤ai≤10121 \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 (1≤l≤r≤n1 \le l \le r \le n, 1≤d≤10121 \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 (1≤l≤r≤n1 \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.

第一行包含三个整数 nn、mm 和 qq(1≤n,q≤2⋅1051 \le n, q \le 2 \cdot 10^5,1≤m≤51 \le m \le 5),分别表示数组 aa 的元素个数、游戏中描述的参数以及查询次数。

第二行包含 nn 个整数 a1a_1, a2a_2, ..., ana_n(1≤ai≤10121 \le a_i \le 10^{12}),即数组 aa 的各元素。

接下来是 qq 行,每行对应一个查询。查询分为两类:第一类查询以一行 11 ll rr dd(1≤l≤r≤n1 \le l \le r \le n,1≤d≤10121 \le d \le 10^{12})表示,其含义是对每个 i∈[l,r]i \in [l, r],将 aia_i 增加 dd;第二类查询以一行 22 ll rr(1≤l≤r≤n1 \le l \le r \le n)表示,其含义是:确定若在数组 aa 的子数组 a[l..r]a[l..r](下标从 ll 到 rr,含端点)上进行游戏,谁将获胜。

至少存在一个类型为 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.

对于每个类型为 22 的查询,如果在对应游戏中先手玩家获胜,则输出 11;如果后手玩家获胜,则输出 22。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页