Sumanto's blog

By Sumanto, 4 years ago, In English

I implemented my solution using LIS(nlogn way) in this Problem F: LIS on Tree. Issue is I'm Facing that,by changing the position changing the snippet code where LIS is getting calculated is giving me correct answer but giving TLE(time limit exceeded) in other way. As far as i can see this does not change the time complexity any how. Am I missing something conceptually on knowledge of LIS or on DFS?

TLE When LIS calculation inside for loop
Accepted after changing LIS snippet outside for loop
  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

In your first code the problem is in this line — set<int> temp=seq; because it copy original set to the new set with time complexity O(n). This is the reason why you first code is giving verdict TLE.