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

×

Multiples of 3 segment tree TLE

I am trying to solve this qstn(https://www.codechef.com/problems/MULTQ3/) using lazy propagation of segment tree but i am getting TLE please help me to optimize

About the code logic

1)Create a segment tree of node

2)each node keep the count of no of 0,1,2 obtained by doing mod in that range i.e a[i]%3

struct node { lli rem[3]; };

rem[0]==count number of all a[i] such that a[i]%3==0

rem[1]==count number of all a[i] such that a[i]%3==1

rem[2]==count number of all a[i] such that a[i]%3==2
 for each node

3)Update the range as per given intrusions

my code link http://ideone.com/U2XNLF

asked 16 Nov '15, 02:13

nil96's gravatar image

2★nil96
18071845
accept rate: 5%

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,840
×1,665
×1,367
×834
×155

question asked: 16 Nov '15, 02:13

question was seen: 766 times

last updated: 16 Nov '15, 02:13