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

×

# need help in FLIPCOIN segment tree problem on CODECHEF

 0 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 69●6 accept rate: 5%

# HERE is your accepted solution...

## Your bug is

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

## Should be

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

answered 02 Oct '18, 16:55

1.4k19
accept rate: 25%

 0 @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 69●6 accept rate: 5% You are welcome :) You need questions on lazy propagation or simply on segment tree ? (05 Oct '18, 00:20) simply on segment tree would be great sir (05 Oct '18, 01:00)
 toggle preview community wiki:
Preview

### Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• link:[text](http://url.com/ "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:

×1,755
×1,173
×176

question asked: 02 Oct '18, 14:27

question was seen: 141 times

last updated: 05 Oct '18, 01:00