ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1100. Final Standings

does only by M ?
Posted by dibrov.bor[SumySU] 5 Nov 2008 00:10
I made solution using stack to store ID data so after sorting by M all ID rows keep sorted in reverse way they meet in input and I got WA1
than I replace stack to queue by replacing "stack" to "queue" and ".top()" to ".front()" only and I got WA2
actually I find nothing in statement about order of ID rows with equal M
Re: does only by M ?
Posted by djosacv 21 Dec 2008 23:19
the order of id rows with same M is implicit in the statement when is said that your sorting algorithm must generate the same ordering that bubblesort generates. Bubblesort is a stable sorting algorithm (it doesn't change the order of records with same keys). So you should use a fast stable sorting algorithm (by the way the usual implementations of quicksort and heapsort aren't stable). Binary-tree and mergesort are stable. Insertion sort also.