663 - Sorting Slides

All about problems in Volume 6. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Try the case.

Input:

Code: Select all

5
0 20 0 20
2 18 2 18
4 16 4 16
6 14 6 14
8 12 8 12
15 15
17 17
13 13
19 19
10 10
0
Output:

Code: Select all

Heap 1
(A,4) (B,2) (C,1) (D,3) (E,5)
Hope it helps.
Ami ekhono shopno dekhi...
HomePage

ral
New poster
Posts: 5
Joined: Tue Jan 09, 2007 12:06 am

Post by ral »

My program works in this test case.
Rodrigo Alves Lima
Brazil

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Change the order of the second part. For example..

Input:

Code: Select all

5
0 20 0 20
2 18 2 18
4 16 4 16
6 14 6 14
8 12 8 12
15 15
10 10
17 17
19 19
13 13
5
0 20 0 20
2 18 2 18
4 16 4 16
6 14 6 14
8 12 8 12
10 10
15 15
13 13
17 17
19 19
0
Output:

Code: Select all

Heap 1
(A,4) (B,3) (C,1) (D,5) (E,2)

Heap 2
(A,5) (B,4) (C,2) (D,3) (E,1)
Hope these help. I thought that you would change the order and verify.
Ami ekhono shopno dekhi...
HomePage

DJWS
Learning poster
Posts: 100
Joined: Sat Oct 11, 2003 3:30 pm
Location: Taiwan
Contact:

Re: 663 - Sorting Slides

Post by DJWS »

Edit: I found the error in my algorithm. AC now.

Here is one of mine implementations:

Code: Select all

Cut.

Post Reply

Return to “Volume 6 (600-699)”