CF717F.Heroes of Making Magic III

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

I’m strolling on sunshine, yeah-ah! And doesn’t it feel good! Well, it certainly feels good for our Heroes of Making Magic, who are casually walking on a one-directional road, fighting imps. Imps are weak and feeble creatures and they are not good at much. However, Heroes enjoy fighting them. For fun, if nothing else.

Our Hero, Ignatius, simply adores imps. He is observing a line of imps, represented as a zero-indexed array of integers aa of length nn , where aia_{i} denotes the number of imps at the ii -th position. Sometimes, imps can appear out of nowhere. When heroes fight imps, they select a segment of the line, start at one end of the segment, and finish on the other end, without ever exiting the segment. They can move exactly one cell left or right from their current position and when they do so, they defeat one imp on the cell that they moved to, so, the number of imps on that cell decreases by one. This also applies when heroes appear at one end of the segment, at the beginning of their walk.

Their goal is to defeat all imps on the segment, without ever moving to an empty cell in it (without imps), since they would get bored. Since Ignatius loves imps, he doesn’t really want to fight them, so no imps are harmed during the events of this task. However, he would like you to tell him whether it would be possible for him to clear a certain segment of imps in the above mentioned way if he wanted to.

You are given qq queries, which have two types:

  • 11 aa bb kk — denotes that kk imps appear at each cell from the interval [a,b][a,b]
  • 22 aa bb - asks whether Ignatius could defeat all imps on the interval [a,b][a,b] in the way described above

输入格式

The first line contains a single integer nn ( 1<=n<=2000001<=n<=200000 ), the length of the array aa . The following line contains nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 0<=ai<=50000<=a_{i}<=5000 ), the initial number of imps in each cell. The third line contains a single integer qq ( 1<=q<=3000001<=q<=300000 ), the number of queries. The remaining qq lines contain one query each. Each query is provided by integers aa , bb and, possibly, kk ( 0<=a<=b<n , 0<=k<=50000<=k<=5000 ).

输出格式

For each second type of query output 11 if it is possible to clear the segment, and 00 if it is not.

输入输出样例

  • 输入#1

    3
    2 2 2
    3
    2 0 2
    1 1 1 1
    2 0 2
    

    输出#1

    0
    1
    

说明/提示

For the first query, one can easily check that it is indeed impossible to get from the first to the last cell while clearing everything. After we add 1 to the second position, we can clear the segment, for example by moving in the following way: .

首页