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

Автор AvadaKedavara, история, 5 месяцев назад, По-английски

In the problem Swaps [problem:https://mirror.codeforces.com/problemset/problem/1573/B], my solution which is of O(n log n) time complexity is not working and giving a tle on test 2, when clearly the problem allows O(n log n) to pass. My solution: [submission:https://mirror.codeforces.com/contest/1573/submission/240104987]. Can somebody explain why this is happening. I know that there is a better solution in the editorial but why should this not pass?

Update: Fixed the problem :>

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

»
5 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Each test case you create an array pos of size 1e6, so your solution works in ~ 1e6 * T, which is quite a lot.

»
5 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

There's also the fact that your solution seems to be wrong?

4
1 5 7 3
4 8 2 6
  • Correct answer: 0
  • Your answer: 1
»
5 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by AvadaKedavara (previous revision, new revision, compare).