shivam_360's blog

By shivam_360, history, 17 months ago, In English

You are given an array a of length n and q queries... A query is in the form [l,r,x].. First, you need to replace each a[i] with a[i]^x for each i from l to r and then answer for the query will be bitwise OR of all a[i] for each i from l to r... here the changes of each query will permanently reflect in the array...and every time we process on the updated array... constraints: N and q <=10^5 A[i] and x <=10^9 L<=r<=N

suggest some of the possible way to approach this problem and some of intuition for in general solving this type of range update questions.... i think...some kind of segment tree or BIT solution must be there...

Full text and comments »

  • Vote: I like it
  • -7
  • Vote: I do not like it

By shivam_360, history, 18 months ago, In English

we have given with an array of coordinate pairs in the form of (x,y) and an integer k, we have to find the number of pairs such that ((x1^x2)+(y1^y2))=k where (x1,y1) is first pair and (x2,y2) is second pair... also i<j, assume the length of the input array to be 10^5 and k can go up to 100..

i know it's some kind of map question where we have separate the relationship in form of x1,y1 and x2,y2 independently...but not able to come up with such relationship... can someone help me with some good approaches and also the intuition behind it... thank you!!

Full text and comments »

  • Vote: I like it
  • -25
  • Vote: I do not like it

By shivam_360, history, 22 months ago, In English

we are given with an array of n integers n<=10^5 , we need to answer q queries q<=10^5 , in each query we are given with l,r and an integer x, for each query we need to answer the summation of |a[i]-x| for all i>=l && i<=r (summation of absolute difference of each number with x in range l and r)..as constraints are big we need to solve each query in less than n... Can anyone suggest some approach with some thought process....

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By shivam_360, history, 2 years ago, In English

can anyone explain this why https://mirror.codeforces.com/contest/18/submission/172558206 this solution gets accepted while https://mirror.codeforces.com/contest/18/submission/172557506 this is giving wrong answer for problem https://mirror.codeforces.com/contest/18/problem/C

Isn't both the same thing??

Full text and comments »

  • Vote: I like it
  • -17
  • Vote: I do not like it

By shivam_360, history, 2 years ago, In English

can anyone suggest some good resource to learn the basic concept and implementation of sparse table?

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it