Блог пользователя pribic

Автор pribic, история, 4 года назад, По-английски

I am trying to solve https://codeforces.me/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.me/contest/86/submission/109548850

  • Проголосовать: нравится
  • -6
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +19 Проголосовать: не нравится

You didn't do Mo's completely correctly, the queries should be sorted by the left block and then by the right endpoint.