Range query to find Longest Increasing Subsequence

Revision en1, by vivace1, 2017-06-18 22:23:13

I was trying to do this question https://www.codechef.com/DEC16/problems/SEAINCR/ . The question says that : Given an array of N integers and given Q queries . Each query asks you to find the length of the Longest Increasing Subsequence from index L to index R in the array. The number of test cases is T. Constraints :

1 ≤ T ≤ 10
1 ≤ A[i], Q, N
Let S be sum of all A[i] in whole file.
1 ≤ S ≤ 1000000
1 ≤ L ≤ R ≤ N
1 ≤ sum of all Q per file ≤ 1000000

I have seen gvaibhav21 's solution  . Many other people have done the same thing. I believe that they have made the DAG(Directed Acyclic Graph) of LIS problem's subproblems and have done something using it . I know how to find LIS using standard O(n^2) DP and also in O(nlogn) using binary search but i am not able to optimize it for range query . Please help .

Tags dag of dp, lis, range query, bit/fenwick tree

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English vivace1 2017-06-19 07:23:12 12
en3 English vivace1 2017-06-19 07:18:43 9
en2 English vivace1 2017-06-18 22:29:05 58
en1 English vivace1 2017-06-18 22:23:13 974 Initial revision (published)