605 - The Rotating Disk
Moderator: Board moderators
-
- Learning poster
- Posts: 60
- Joined: Tue Aug 13, 2002 2:39 am
- Location: Mexico
605 - The Rotating Disk
How to solve it?. I can think about Greedy, but some cases my heuristhics don't work. Or search, but won't be too large store partial permutations?


-
- New poster
- Posts: 35
- Joined: Sat Jan 05, 2002 2:00 am
- Contact:
Re: 605
Well, just analyse the problem to see when it is soluable, when it is not. If yes, my algorithm is to place all the numbers to their places, one by one.Miguel Angel wrote:How to solve it?. ?
A propos, does anybody know if there is any problem, which can be solved by using some heuristics?
605 - The Rotating Disk...limit for n?!?
I have two doubts regarding 605.
(1) Is there supposed to be a limit for n? It is not given in the problem!
(2) Does anyone know a deterministic approach for converting a set of numbers to natural order? I have not been able to think of a way, and am about to attempt a heuristic search
(1) Is there supposed to be a limit for n? It is not given in the problem!
(2) Does anyone know a deterministic approach for converting a set of numbers to natural order? I have not been able to think of a way, and am about to attempt a heuristic search

Wake me up inside.
605 ???
Excuse me, but there is small problem in this problem 
Please tell me why
the code

Please tell me why
the code
gives me#include <stdio.h>
void main()
#include <stdio.h>
void main()
{
int a;
scanf("%d",&a);
while (a)
{
printf("%d",a);
scanf("%d",&a);
}
}
, but not a wrong answer ??Time Limit Exceeded 0:10.064
-
- A great helper
- Posts: 383
- Joined: Mon Oct 18, 2004 8:25 am
- Location: Bangladesh
- Contact:
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 pm
Yes, the problem is slightly under-specified.
(1) I use 4 <= n <= 256.
(2) It doesn't state that the solution has to be optimal. My algo performs < 4*n*n steps worst case, but significantly less on average. I don't know what the output limit is, but I suppose it's not too difficult to write a program that reaches it.
(1) I use 4 <= n <= 256.
(2) It doesn't state that the solution has to be optimal. My algo performs < 4*n*n steps worst case, but significantly less on average. I don't know what the output limit is, but I suppose it's not too difficult to write a program that reaches it.
-
- New poster
- Posts: 5
- Joined: Fri Jan 25, 2008 9:27 pm
Re: 605
You can write another programme to find out when the track can be solved.Yu Fan wrote:in this problem,how can we detemine whether the track can be solved?
thanks in advance
Re: 605 - The Rotating Disk
I'm still fighting the prob and cannot get accepted. Could someone please share with me some clarifications of the tasks? The description is rather vague.
1. What is "the natural order"? Is the reverse "3 2 1" natural?
2. How do you understand "You must not display moves around the whole
track."? Ain't we allowed to do anything when N == 4 or we are allowed
but we are supposed not to print it?
3. Could someone please show me your correct output for the test case below?
4. Do you know about other nasty traps in this problem description?
EDIT: I finally got AC Here are the answer (from email from Cedric Lin; thanks!):
1. "natural order" is just increasing order, I believe. So "3 2 1" is not natural.
2. I think what is meant by "moves around the whole track" are moves that would wraparound the output line. (So you can't have "1 2* 3 4 5 6 7 8 *9 10" to indicate that you are rotating the disk with 9, 10, 1 and 2.)
BTW: I checked that there are no inputs with N < 4.
1. What is "the natural order"? Is the reverse "3 2 1" natural?
2. How do you understand "You must not display moves around the whole
track."? Ain't we allowed to do anything when N == 4 or we are allowed
but we are supposed not to print it?
3. Could someone please show me your correct output for the test case below?
4. Do you know about other nasty traps in this problem description?
Code: Select all
1
1 2
2 1
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 3 2
1 4 2 3
5 4 3 2 1
6 5 4 3 2 1
7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8
1. "natural order" is just increasing order, I believe. So "3 2 1" is not natural.
2. I think what is meant by "moves around the whole track" are moves that would wraparound the output line. (So you can't have "1 2* 3 4 5 6 7 8 *9 10" to indicate that you are rotating the disk with 9, 10, 1 and 2.)
Code: Select all
1
1 2
2 1
1 2 3
1 3 2
It is not possible to rearrange these disks in natural order.
2 1 3
It is not possible to rearrange these disks in natural order.
2 3 1
3 1 2
3 2 1
It is not possible to rearrange these disks in natural order.
1 2 3 4
1 2 4 3
It is not possible to rearrange these disks in natural order.
1 3 2 4
It is not possible to rearrange these disks in natural order.
1 3 4 2
It is not possible to rearrange these disks in natural order.
1 4 3 2
*2 3 4 1*
1 4 2 3
It is not possible to rearrange these disks in natural order.
5 4 3 2 1
*2 3 4 5* 1
6 5 4 3 2 1
5 4 *6 1 2 3*
*1 6 4 5* 2 3
1 *2 5 4 6* 3
1 2 *3 6 4 5*
*6 3 2 1* 4 5
6 3 *5 4 1 2*
6 *1 4 5 3* 2
6 1 *2 3 5 4*
*3 2 1 6* 5 4
3 *5 6 1 2* 4
*1 6 5 3* 2 4
1 *2 3 5 6* 4
*5 3 2 1* 6 4
5 3 *4 6 1 2*
5 *1 6 4 3* 2
5 1 *2 3 4 6*
*3 2 1 5* 4 6
3 *4 5 1 2* 6
*1 5 4 3* 2 6
1 *2 3 4 5* 6
7 6 5 4 3 2 1
It is not possible to rearrange these disks in natural order.
8 7 6 5 4 3 2 1
8 7 6 5 *1 2 3 4*
8 7 *2 1 5 6* 3 4
*1 2 7 8* 5 6 3 4
1 2 *6 5 8 7* 3 4
1 2 6 5 *4 3 7 8*
1 2 *3 4 5 6* 7 8