首页 > 代码库 > 【USACO】transformations
【USACO】transformations
{ID: anniel11PROG: transformLANG: PASCAL}Program transform;Var temp:boolean; c:char; i,j,n,sum,head,tail:longint; map1,map2:array[1..10,1..10] of boolean; f:array[0..100000,1..2] of integer; flag,flag2:boolean;Begin fillchar(map1,sizeof(map1),false); fillchar(map2,sizeof(map2),false); Assign(input, ‘transform.in‘); reset(input); Assign(output, ‘transform.out‘); Rewrite(output); Readln(n); flag2:=false; for i:=1 to n do begin for j:=1 to n do begin read(c); if c=‘@‘ then map1[i,j]:=true; end; readln; end; for i:=1 to n do begin for j:=1 to n do begin read(c); if c=‘@‘ then map2[i,j]:=true; end; readln; end; //#1 i‘=j j‘=n-i+1 flag:=true; for i:=1 to n do for j:=1 to n do if map2[i,j]<>map1[j,n-i+1] then begin flag:=false; break; end; if flag then writeln(1); if flag then flag2:=true; //#2 i`=n-i+1 j‘=n-j+1 flag:=true; for i:=1 to n do for j:=1 to n do if map2[i,j]<>map1[n-i+1,n-j+1] then begin flag:=false; break; end; if flag then writeln(2); if flag then flag2:=true; //#3 i‘=n-j+1 j‘=i flag:=true; for i:=1 to n do for j:=1 to n do if map2[i,j]<>map1[n-j+1,i] then begin flag:=false; break; end; if flag then writeln(3); if flag then flag2:=true; //#4 i‘=i j‘=n-j+1 flag:=true; for i:=1 to n do for j:=1 to n do if map2[i,j]<>map1[i,n-j+1] then begin flag:=false; break; end; if flag then writeln(4); if flag then flag2:=true; //#5 #3 reflect right half flag:=true; for i:=1 to n do for j:=1 to n do begin if i<=n div 2 then if map2[i,j]<>map1[n-j+1,i] then begin flag:=false; break; end; if i>n div 2 then if map2[i,j]<>map1[j,n-i+1] then begin flag:=false; break; end; end; if flag then writeln(5); if flag then flag2:=true; //#6 i‘=i j‘=j flag:=true; for i:=1 to n do for j:=1 to n do if map2[i,j]<>map1[i,j] then begin flag:=false; break; end; if flag then writeln(6); if flag then flag2:=true; //#7 if flag2=false then writeln(7); close(input); close(output);End.{1 2 3 44 5 6 87 8 9 91 1 1 11,1 -> 1,31,2 2,31,3 3,32,1 1,22,2 2,22,3 3,2 }
【USACO】transformations
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。