You are not logged in. Please login at www.codechef.com 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

4★pavitra_ag
696
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];$

link

answered 02 Oct '18, 16:55

l_returns's gravatar image

5★l_returns
1.4k19
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 :)

link

answered 04 Oct '18, 18:15

pavitra_ag's gravatar image

4★pavitra_ag
696
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
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