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

Pascal编译错误你在逗我?就这样看不起?

Posted by Caitlyn at 2015-09-12 10:58:03 on Problem 2488
const
  px:array[1..8] of -2..2=(-1,1,1,-1,-2,2,2,-2);
  py:array[1..8] of -2..2=(-2,-2,2,2,-1,-1,1,1);
var
  flag:array[1..26,1..26] of boolean;
  road:array[1..26,1..2] of integer;
  n,p,q,m:integer;
  check:boolean;
  procedure pre(p,q:integer);
  var
    i,j:integer;
  begin
    fillchar(flag,sizeof(flag),false);
    fillchar(road,sizeof(road),0);
    for i:=1 to q do
      for j:=1 to p do
        flag[i,j]:=true;
    road[1,1]:=1; road[1,2]:=1; flag[1,1]:=false;
  end;
  procedure print(k:integer);
  var
    i:integer;
  begin
    check:=false;
    for i:=1 to k do write(chr(road[i,1]+64),road[i,2]);
    writeln;
  end;
  procedure dfs(x,y,k:integer);
  var
    i,nx,ny:integer;
  begin
    if k=p*q then print(k)
    else
      for i:=1 to 8 do
      begin
        nx:=x+px[i];
        ny:=y+py[i];
        if (nx>0) and (nx<=q) and (ny>0) and (ny<=p) and flag[nx,ny] and check then
        begin
          road[k+1,1]:=nx;
          road[k+1,2]:=ny;
          flag[nx,ny]:=false;
          dfs(nx,ny,k+1);
          flag[nx,ny]:=true;
        end;
      end;
    end;
begin
  readln(n);
  for m:=1 to n do
  begin
    readln(p,q);
    pre(p,q);
    check:=true;
    writeln('Scenario #',m,':');
    dfs(1,1,1);
    if check then writeln('impossible');
    writeln;
  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