• [B] a simple problem

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Radical has an array consisting of n integers.Each integer a[i] equals to 1,or to -1.Also Radical asks you m queries.
    Query number i is given as a pair of integers L[i],R[i](1<=L[i]<=R[i]<=n)
    The response to the query will be integer 1, if the elements of array a can be rearranged so as the sum a[L[i]] + ... + a[R[i]] = 0,
    otherwise the response to the query will be integer 0.
  • 输入
  • The first line contains integers n and m(1<=n,m<=2*10^5).The second line contains n integers,a[1],a[2]...a[n].Next m lines
    contain Radical's queries.The i-th line contains integers L[i],R[i](1<=L[i]<=R[i]<=n)
  • 输出
  • Print m integers — the responses to Radical's queries in the order they occur in the input.
  • 样例输入
  • 2 3
    1 -1
    1 1
    1 2
    2 2
  • 样例输出
  • 0
    1
    0
  • 提示
  • 来源
  • Radical@NBUT
  • 操作

显示春菜