usaco1.2 transform 2008.11.5
{
ID:
PROG: transform
LANG: PASCAL
}
{刚开始,以为是一道很难的题,后来发现很简单。
只是我把镜面反射弄错了,我以为是沿x轴对称,结果是沿y轴对称。
其中,变量k还带成n了,找了半天的错,终于找到了 一定不要带错变量
还有,const n=10,这个总是忘了把它从调试的值改成最大值}
program kakashi;
const n=10;
type
arr=array[1..n,1..n]of char;
var
i,j,k:longint;
f1,f2:text;
a,x,e:arr;
flag:boolean;
procedure deal(x1,x2:arr);
var
i,j:longint;
si:boolean;
begin
si:=true;
for i:=1 to k do
for j:=1 to k do
if x1[i,j]<>x2[i,j] then si:=false;
if si then flag:=true;
end;
procedure try1(y:arr);
var
i,j:longint;
begin
for i:=1 to k do
for j:=1 to k do
x[i,j]:=y[k+1-j,i];
end;
procedure try2(y:arr);
var
i,j:longint;
begin
for i:=1 to k do
for j:=1 to k do
x[i,j]:=y[k+1-i,k+1-j];
end;
procedure try3(y:arr);
var
i,j:longint;
begin
for i:=1 to k do
for j:=1 to k do
x[i,j]:=y[j,i];
end;
procedure try4(y:arr);
var
i,j:longint;
begin
for i:=1 to k do
for j:=1 to k do
x[i,j]:=y[i,k+1-j];
end;
procedure try5(yy:arr);
var
tt:arr;
i,j:longint;
begin
try4(yy);
tt:=x;
try1(tt);
deal(x,e);
if not(flag) then
begin
try2(tt);
deal(x,e);
if not(flag) then
begin
try3(tt);
deal(x,e);
end;
end;
end;
begin
assign(f1,'transform.in');
reset(f1);
assign(f2,'transform.out');
rewrite(f2);
readln(f1,k);
for i:=1 to k do
readln(f1,a[i]);
for i:=1 to k do
readln(f1,e[i]);
flag:=false;
try1(a);
deal(x,e);
if flag then writeln(f2,1) else
begin
try2(a);
deal(x,e);
if flag then writeln(f2,2) else
begin
try3(a);
deal(x,e);
if flag then writeln(f2,3) else
begin
try4(a);
deal(x,e);
if flag then writeln(f2,4)
else
begin
try5(a);
if flag then writeln(f2,5) else
begin
deal(a,e);
if flag then writeln(f2,6) else writeln(f2,7)
end;
end;
end;
end;
end;
close(f1);
close(f2);
end.
data
TASK: transform
LANG: PASCAL
Compiling...
Compile: OK
Executing...
Test 1: TEST OK [0 secs]
Test 2: TEST OK [0.004 secs]
Test 3: TEST OK [0 secs]
Test 4: TEST OK [0.004 secs]
Test 5: TEST OK [0.004 secs]
Test 6: TEST OK [0 secs]
Test 7: TEST OK [0.004 secs]
Test 8: TEST OK [0.004 secs]
All tests OK.
Your program('transform') produced all correct answers! This is your
submission #7 forthis problem. Congratulations!
Here are the test data inputs:
------- test 1-------
3
---
---
---
---
-@-
---
------- test 2-------
5
-@@@-
-@@--
-@---
-----
-----
-----
----@
---@@
--@@@
-----
------- test 3-------
5
@@@@@
@---@
@@@@@
@@@@@
@@@@@
@@@@@
@@@@@
@@@@@
@---@
@@@@@
------- test 4-------
6
-@-@-@
@-@-@-
-@-@-@
@-@-@-
-@-@-@
@-@-@-
@-@-@-
-@-@-@
@-@-@-
-@-@-@
@-@-@-
-@-@-@
------- test 5-------
3
@@@
---
@@@
@@@
---
@@@
------- test 6-------
4
@@@@
@@@@
-@@@
@@@@
@@@@
@@@@
@@@-
@@@@
------- test 7-------
4
@-@@
@@@@
@@@@
@@@@
@@@@
@@@@
@@@@
@-@@
------- test 8-------
10
@--------@
----------
----------
----------
----------
----------
----------
----------
----------
----------
@---------
----------
----------
----------
----------
----------
----------
----------
----------
---------@
----------------------