ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1519. Formula 1

what's the edition of ural's pascal?why my code got Compilation error?
Posted by xiaoc 6 Aug 2011 11:41
const
  zs=699967;
type
  size=record
    di,zhuan:longint;
    x,y:integer;
  end;
var
  dz:array[0..14329,1..2] of longint;
  dui:Array[0..14329,1..2] of int64;
  hash:array[0..700000] of size;
  xx,s1,s2,pd,n,m,i1,i2,zhuan,l1,l2,nzhuan,k:longint;
  d:Array[1..2] of longint;
  map:Array[0..13,0..13] of  char;
  san:array[0..13] of longint;
  zhi:int64;
  i,j,ii:longint;
procedure swap(var a,b:longint);
var
  t:longint;
begin
  t:=a; a:=b; b:=t;
end;
function zb(nzhuan:longint):longint;
begin
  zb:=nzhuan mod  zs;
  while (hash[zb].x=i) and (hash[zb].y=j) and (hash[zb].zhuan<>nzhuan) do
  begin
    inc(zb);
    zb:=zb mod zs;
  end;
end;


procedure jiaru(nzhuan:longint;zhi:int64);
var
  nzb:longint;
begin
  if ((map[i+1,j]='*')and (nzhuan div san[j-1] mod 3>0))
    or ((map[i,j+1]='*')and (nzhuan div san[j] mod 3>0)) then
    exit;
  nzb:=zb(nzhuan);
  if (hash[nzb].x<>i)or (hash[nzb].y<>j) then
  begin
    inc(d[i2]);
    dz[d[i2],i2]:=nzhuan;
    dui[d[i2],i2]:=zhi;
    hash[nzb].x:=i; hash[nzb].y:=j;
    hash[nzb].di:=d[i2];
    hash[nzb].zhuan:=nzhuan;
  end else begin
    inc(dui[hash[nzb].di,i2],zhi);
  end;
end;
begin
  san[0]:=1;
  for i:=1 to 13 do san[i]:=san[i-1]*3;
  readln(n,m);
  for i:=1 to n do
  begin
    for j:=1 to m do
    begin
      read(map[i,j]);
      if i=1 then map[i-1,j]:='*';
      if i=n then map[i+1,j]:='*';
      if j=1 then map[i,j-1]:='*';
      if j=m then map[i,j+1]:='*';
    end;
    readln;
  end;
  map[0,0]:='*'; map[0,m]:='*';
  for i:=0 to 600000 do
  hash[i].x:=0;
  dui[1,1]:=1; dz[1,1]:=0;
  i1:=1; i2:=2;
  d[1]:=1;
  for i:=1 to n do
  begin
    for j:=1 to m do
    begin
      d[i2]:=0;
      for ii:=1 to d[i1] do
      begin
        zhuan:=dz[ii,i1];
        zhi:=dui[ii,i1];
        l1:=zhuan div san[j-1] mod 3;
        l2:=zhuan div san[j] mod 3;
        if l1+l2=3 then
        begin
          if (l1=1)and (l2=2)and ((i<>n) or (j<>m)) then continue;
          nzhuan:=zhuan-san[j-1]*l1-san[j]*l2;
          jiaru(nzhuan,zhi);
        end else
        if l1+l2=0 then
        begin
          if map[i,j]='.' then
          nzhuan:=zhuan+san[j-1]*1+san[j]*2 else
          nzhuan:=zhuan;

          jiaru(nzhuan,zhi);
        end else if l1=l2 then
        begin
          if l1=1 then
          begin
            pd:=0;
            k:=j+1;
            while pd<>1 do
            begin
              inc(k);
              xx:=zhuan div san[k-1] mod 3;
              if xx=1 then dec(pd);
              if xx=2 then inc(pd);
              if pd=1 then s1:=k;
            end;
            nzhuan:=zhuan-san[j-1]-san[j]-san[s1-1];
            jiaru(nzhuan,zhi);
          end else begin
            pd:=0;
            k:=j;
            while pd<>1 do
            begin
              dec(k);
              xx:=zhuan div san[k-1] mod 3 ;
              if xx=1 then inc(pd);
              if xx=2 then dec(pd);
              if pd=1 then s2:=k;
            end;
            nzhuan:=zhuan-san[j-1]*2-san[j]*2+san[s2-1];
            jiaru(nzhuan,zhi);
          end;
        end else
        begin
          jiaru(zhuan,zhi);
          nzhuan:=zhuan-san[j-1]*l1-san[j]*l2;
          swap(l1,l2);
          nzhuan:=nzhuan+san[j-1]*l1+san[j]*l2;
          jiaru(nzhuan,zhi);
        end;
      end;
      swap(i1,i2);
    end;
    j:=m;
    d[i2]:=0;
    for ii:=1 to d[i1] do
    begin
      if (dz[ii,i1]div san[j]) >0then
      begin
        writeln('nimeia');
        continue;
      end;
      inc(d[i2]);
      dz[d[i2],i2]:=dz[ii,i1]*3;
      dui[d[i2],i2]:=dui[ii,i1];

    end;
    swap(i1,i2);
  end;
  if d[i1]<>1 then writeln('0')else
  writeln(dui[1,i1]);
end.





Re: what's the edition of ural's pascal?why my code got Compilation error?
Posted by xiaoc 6 Aug 2011 12:04
I see!
ural no function ,only procedure!
(haha Chinglish!)