Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么我总是WrongAnsser

Posted by nike0good at 2012-08-12 22:24:18 on Problem 4001
Program P4001;
Var
   n,x,y,i,j,x1,y1,yredg:longint;
   c:char;
   map:array[-100..100,-100..100] of longint;
   fx,fy:array[1..100] of longint;
function inside(x,y:longint):boolean;
begin
   if (1<=x) and (x<=10) and (1<=y) and (y<=9) then exit(true);
   exit(false);
end;
Function solve(x,y:longint):boolean; //weather red win
var
   i,j,p,sum,xd,yd:longint;
begin
   solve:=false;
   for i:=x+1 to 10 do
      if map[i,y]>0 then
      begin
         if map[i,y]=2 then exit(true)
         else
         begin
            for j:=i+1 to 10 do
            begin
               if map[j,y]>0 then
               begin
                  if map[j,y]=3 then exit(true);
                  break;
               end;
            end;
         end;
         break;
      end;
   for i:=x-1 downto 1 do
      if map[i,y]>0 then
      begin
         if map[i,y]=2 then exit(true)
         else
         begin
            for j:=i-1 downto 1 do
            begin
               if map[j,y]>0 then
               begin
                  if map[j,y]=3 then exit(true);
                  break;
               end;
            end;
         end;
         break;
      end;
   for i:=y+1 to 9 do
      if map[x,i]>0 then
      begin
         if map[x,i]=2 then exit(true)
         else
         begin
            for j:=i+1 to 9 do
            begin
               if map[x,i]>0 then
               begin
                  if map[x,i]=3 then exit(true);
                  break;
               end;
            end;
         end;
         break;
      end;

   for i:=y-1 downto 1 do
      if map[x,i]>0 then
      begin
         if map[x,i]=2 then exit(true)
         else
         begin
            for j:=i-1 downto 1 do
            begin
               if map[x,i]>0 then
               begin
                  if map[x,i]=3 then exit(true);
                  break;
               end;
            end;
         end;
         break;
      end;
{
   for i:=1 to n do
   begin
      p:=map[fx[i],fy[i]];
      if p=4 then
         begin
          xd:=x-fx[i];
          yd:=y-fy[i];
          if (xd<>0) and (yd<>0) then
          begin
             if (xd=-1) and (yd=-2) then if map[x+1,y+1]=0 then solve:=true;
             if (xd=-2) and (yd=-1) then if map[x+1,y+1]=0 then solve:=true;
             if (xd=1) and (yd=2) then if map[x-1,y-1]=0 then solve:=true;
             if (xd=2) and (yd=1) then if map[x-1,y-1]=0 then solve:=true;
             if (xd=1) and (yd=-2) then if map[x-1,y+1]=0 then solve:=true;
             if (xd=2) and (yd=-1) then if map[x-1,y+1]=0 then solve:=true;
             if (xd=-1) and (yd=2) then if map[x+1,y-1]=0 then solve:=true;
             if (xd=-2) and (yd=1) then if map[x+1,y-1]=0 then solve:=true;


          end;
       end;
   end;
}
   if (inside(x-2,y-1)) then if map[x-2,y-1]=4 then if map[x-1,y-1]=0 then exit(true);
   if (inside(x+2,y+1)) then if map[x+2,y+1]=4 then if map[x+1,y+1]=0 then exit(true);
   if (inside(x-1,y-2)) then if map[x-1,y-2]=4 then if map[x-1,y-1]=0 then exit(true);
   if (inside(x+1,y+2)) then if map[x+1,y+2]=4 then if map[x+1,y+1]=0 then exit(true);
   if (inside(x+2,y-1)) then if map[x+2,y-1]=4 then if map[x+1,y-1]=0 then exit(true);
   if (inside(x+1,y-2)) then if map[x+1,y-2]=4 then if map[x+1,y-1]=0 then exit(true);
   if (inside(x-2,y+1)) then if map[x-2,y+1]=4 then if map[x-1,y+1]=0 then exit(true);
   if (inside(x-1,y+2)) then if map[x-1,y+2]=4 then if map[x-1,y+1]=0 then exit(true);

end;
function main:boolean; //weather checkmate
var
   i,j:longint;
begin
   main:=true;
   if y>4 then if not(solve(x,y-1)) then main:=false;
   if y<6 then if not(solve(x,y+1)) then main:=false;
   if x>1 then if not(solve(x-1,y)) then main:=false;
   if x<3 then if not(solve(x+1,y)) then main:=false;

end;
Begin
   readln(n,x,y);
   while (n+x+y>0) do
   begin
      fillchar(map,sizeof(map),0);
      for i:=1 to n do
      begin
         read(c);
         while (c<>'G') and (c<>'R') and (c<>'C') and (c<>'H') do read(c);
         readln(x1,y1);
         fx[i]:=x1;
         fy[i]:=y1;
         if c='G' then map[x1,y1]:=2
         else if c='R' then map[x1,y1]:=2
         else if c='C' then map[x1,y1]:=3
         else if c='H' then map[x1,y1]:=4;
      end;
      if main then writeln('YES')
      else writeln('NO');
      readln(n,x,y);
   end;
End.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator