Help Needed In Recent Contest's Problem C.

Revision en2, by noobCoderUltraProMax, 2022-05-08 21:12:48

My Code link:https://mirror.codeforces.com/contest/1678/submission/156355337

My Logic: Store all Pairs [Ai,Aj] where Ai>Aj in a 2D Vector and similarly do for Ai<Aj. Now Make 4 length arrays using these two arrays as they have required Pa < Pc and Pb>Pd pairs. If they meet the given condition check if position of elements of subsequence in original array is sorted or not using map, if sorted increment the answer.

Problem: It TLE's.

Thinking: I tired to think of optimization but unable to come up with. So can anyone help?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English noobCoderUltraProMax 2022-05-08 21:12:48 2 Tiny change: 'equired Pa<Pc and Pb>' -> 'equired Pa < Pc and Pb>'
en1 English noobCoderUltraProMax 2022-05-08 21:12:10 570 Initial revision (published)