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

×

SPOJ CODECHEF TEMPLEQ TLE

http://www.spoj.com/problems/TEMPLEQ/

http://www.codechef.com/problems/TEMPQUE

https://ideone.com/0WIYXr

I have mapped the indices of sorted elements with the original array using HashMap. The time complexity of my solution is O(logn) for type 1 and 2 queries.
And for type 3 queries its O(n+logn)
I am only using an array,not a segment tree.
Can anyone explain the O(nlogn+ q*log^2n) approach and the O(nlogn+ q*logn) approach? The solution I posted is taking 9.89 secs on the worst case input of 499999 queries of type 3 and 1 query of type 2.

asked 10 Jan '15, 14:45

abeyaar's gravatar image

1★abeyaar
33422140
accept rate: 30%

edited 19 Jan '15, 16:04

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,135
×1,038

question asked: 10 Jan '15, 14:45

question was seen: 3,474 times

last updated: 19 Jan '15, 16:04