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


Multiples of 3 segment tree TLE

I am trying to solve this qstn( 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

asked 16 Nov '15, 02:13

nil96's gravatar image

accept rate: 5%

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: 16 Nov '15, 02:13

question was seen: 691 times

last updated: 16 Nov '15, 02:13