/ Vijos / 讨论 / 问答 /

求助!错了第四个点

https://www.vijos.org/p/1335
代码

var
  a:array[0..10,0..10] of longint;
  i,j,k,n:longint; 
function gd(x,y:longint):longint;
begin
  exit(a[x,y]+a[x+1,y]+a[x+2,y]+a[x,y+1]+a[x+1,y+1]+a[x+2,y+1]+a[x,y+2]+a[x+1,y+2]+a[x+2,y+2]);
end;
function pd:boolean;
var
  sum,i,j:longint;
begin
  for i:=1 to 9 do
  begin
    sum:=0;
    for j:=1 to 9 do
    sum:=sum+a[i,j];
    if sum<>45 then exit(false);
  end;
  for i:=1 to 9 do
  begin
    sum:=0;
    for j:=1 to 9 do
    sum:=sum+a[j,i];
    if sum<>45 then exit(false);
  end;
  sum:=gd(1,1);
  if sum<>45 then exit(false);
  sum:=gd(1,4);
  if sum<>45 then exit(false);
  sum:=gd(1,7);
  if sum<>45 then exit(false);
  sum:=gd(4,1);
  if sum<>45 then exit(false);
  sum:=gd(4,4);
  if sum<>45 then exit(false);
  sum:=gd(4,7);
  if sum<>45 then exit(false);
  sum:=gd(7,1);
  if sum<>45 then exit(false);
  sum:=gd(7,4);
  if sum<>45 then exit(false);
  sum:=gd(7,7);
  if sum<>45 then exit(false);
  exit(true);
end;
begin
  readln(n);
  for i:=1 to n do
  begin
    for j:=1 to 9 do
      for k:=1 to 9 do
    read(a[j,k]);
    if pd then writeln('Right')
    else writeln('Wrong');
  end;
end.

0 条评论

目前还没有评论...