[Help] MO's algoridhm getting TLE — Java

Правка en2, от pribic, 2021-03-10 13:11:32

I am trying to solve https://codeforces.com/contest/86/problem/D where I am using MO's traversal but I am keep getting TLE. Can someone please review my code and help me with slowness? I tried following things so far:

  1. Changed the way we read input. Reading entire line and converting them to int in memory
  2. Changed from Array to ArrayList since I heard Arrays.sort() has O(n^2) in some cases.

I am not sure if there is a flaw in logic or some library methods which is slowing down and giving TLE.

Submission: https://codeforces.com/contest/86/submission/109548850

Теги #mos algorithm, #help, #tle

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский pribic 2021-03-10 13:11:32 7 Tiny change: ' so far:\n1. Chang' -> ' so far:\n\n1. Chang'
en1 Английский pribic 2021-03-10 13:08:42 628 Initial revision (published)