You are not logged in. Please login at to post your questions!


need help in FLIPCOIN segment tree problem on CODECHEF

Can someone tell me what is wrong in my implementation of lazy propagation in this PROBLEM. If my lazy node is 1 then that segment needs to be flipped and if 0 then no change. I am just able to pass sample test case. Someone please help:) CODE.

asked 02 Oct '18, 14:27

pavitra_ag's gravatar image

accept rate: 5%

HERE is your accepted solution...

Your bug is


Should be

$lazy[node*2]=!$ $lazy[node*2]);$
$lazy[node*2+1]=!$ $lazy[node*2+1];$


answered 02 Oct '18, 16:55

l_returns's gravatar image

accept rate: 25%

edited 02 Oct '18, 17:03

@l_returns Thanks for the help. Sorry for the delay. Can you please suggest some problems on segment tree to practice from basic to intermediate level :)


answered 04 Oct '18, 18:15

pavitra_ag's gravatar image

accept rate: 5%

You are welcome :)
You need questions on lazy propagation or simply on segment tree ?

(05 Oct '18, 00:20) l_returns5★

simply on segment tree would be great sir

(05 Oct '18, 01:00) pavitra_ag4★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 02 Oct '18, 14:27

question was seen: 141 times

last updated: 05 Oct '18, 01:00