Swaps in Permutation problem(solved,a stupid bug:DDD)

Правка en5, от Tornad0, 2016-07-22 07:21:37

Hi all,

I have difficulty on a problem on codeforces http://mirror.codeforces.com/problemset/problem/691/D

my submission is : http://mirror.codeforces.com/contest/691/submission/19308291

I think my idea is right, I used dsu to group several numbers and downsort numbers inside the groups. But I don't know why I am still wrong answer at test21. The idea is simple, but I can't find what's wrong. Anyone please help me, thanks:D

How to find bugs when you think your algorithms and implementation is correct,BTW?

Edit: Bug found:)))

I should calculate p[i]=parent(i) before I use p[i] . I thought it was automatically done by merging, however it is not :DDDD

Теги buggy, stupid:dd

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en5 Английский Tornad0 2016-07-22 07:21:37 178
en4 Английский Tornad0 2016-07-22 05:41:47 86
en3 Английский Tornad0 2016-07-21 22:39:04 30
en2 Английский Tornad0 2016-07-21 22:33:32 27
en1 Английский Tornad0 2016-07-21 22:30:25 413 Initial revision (published)