# include
using namespace std;
Int main ()
{
Int cot=0; Char s;
While (1)
{
The fflush (stdin);
Char puzzle [10] [10]={0};
Int x=0, y=0;
Int I=0, j=0;
for(i=1; I<=5; I++)
{
For (j=1; j<=5; J++)
{
char ch;
Ch=getchar ();
While (ch=='\ n')
{ch=getchar (); }
Puzzle [I] [j]=ch;
If (ch==' ') {x=j; Y=I; }
If (ch=='Z') return 0;
}
}
Char ins=0;
Int flag=1;
While (1)
{
Ins=getchar ();
If (ins=='A')
{
If (y - 1 & lt;=0) {
flag=1;
break;
}
The else
{
Swap (puzzle [y] [x], puzzle [1] y [x]).
Y=y - 1;
continue;
}
}
If (ins=='B')
{
If (y + 1 & gt; {
=6)flag=1;
break;
}
The else
{
Swap (puzzle [y] [x], puzzle [y + 1], [x]).
Y=y + 1;
continue;
}
}
If (ins=='L')
{
If (x - 1 & lt;=0) {
flag=1;
break;
}
The else
{
Swap (puzzle [y] [x], puzzle [y]] [x - 1);
X=x - 1;
continue;
}
}
If (ins=='R')
{
If (x + 1 & gt; {
=6)flag=1;
break;
}
The else
{
Swap (puzzle [y] [x], puzzle [y] [x + 1]).
X=x + 1;
continue;
}
}
If (ins=='0')
{
flag=0;
break;
}
}
Cot++;
If (cot!
=1)Coutcout <"Puzzle #" & lt; if(! Flag)
for(int i=1; i <6; I++) {
For (int j=1; J & lt; 6; J++) {
If (j!=1) cout & lt; <"';
cout}
cout}
The else
{
cout <"This puzzle has no final configuration." & lt;}
}
return 0;
}
This is the input
TRGSJ
XDOKI
M VLN
WPABE
UQHCF
ARRBBL0
ABCDE
FGHIJ
KLMNO
PQRS
TUVWX
AAA
LLLL0
ABCDE
FGHIJ
KLMNO
PQRS
TUVWX
AAAAABBRRRLL0
Z
According to the sample output is why or WA a days still didn't find out where there is a problem...
CodePudding user response:
No attention to the problem of crossing the line, x, y of crossing the line to do judgment