rofi93's blog

By rofi93, history, 3 years ago, In English

I was trying to solve this problem using AVL tree, but getting RE. Can't find out what I'm doing wrong. Can someone help me ??

Solution — https://ideone.com/l7a0jg

UPDATE

Got AC. The bug was I was accessing directly root->subtree_size without checking if the root is NOT NULL.

Here's my AVL tree implementation, pastebin and ideone

Read more »

 
 
 
 
  • Vote: I like it
  • +2
  • Vote: I do not like it

By rofi93, history, 5 years ago, In English

Problem: You are given an array consisting of n elements and q queries in the form of [L,R]. You have to output the maximum occurrences of a number in the segment [L,R] for each query.

How to solve these kind of problems using Segment Tree ?? I can solve this using sqrt decomposition, but got stuck trying to solve using segment tree.

Read more »

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it

By rofi93, 6 years ago, In English

In this problem 459B - Пашмак и цветы range of n is 2*10^5 and i mistakenly declared the array of size 1*10^5. For this mistake i should have been given RE (Runtime Error), but instead why i was given TLE (Time Limit Exceeded) ? It took me a long time to figure out the bug because of weird verdict !! check my submissions- 13244700 and 13244705

Read more »

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it