sine吧 关注:24贴子:175
  • 61.186.207.*
var
  f:array[-1..9,-1..9]of 0..1;
  s:array[0..10]of integer;
  visited:array[0..9]of boolean;

procedure inputof;
var i,j:integer;
begin
  for i:=-1 to 9 do
    for j:=i to 9 do
    begin
      read(f[i,j]);
      f[j,i]:=f[i,j];
    end;
end;
procedure outputof;
var i:integer;
begin
  for i:=1 to 10 do write(s[i]);
end;


procedure concl(a,b:integer);
var
i:integer;
begin
  if a=11 then outputof;
  s[a]:=b;visited[b]:=true;
  for i:=0 to 9 do
  if (f[b,i]=1)and(not(visited[i])) then concl(a+1,i);
end;



begin
  inputof;
  concl(0,-1);
end.


1楼2006-10-30 17:45回复
    • 61.186.207.*
    1 1 1 1 1 1 1 1 1 1 1
    0 1 0 0 0 0 0 1 1 0
    0 0 1 1 0 0 1 1 1
    0 0 0 0 0 0 1 0
    0 0 0 0 1 1 1
    0 0 0 0 1 1
    0 1 0 1 1
    0 0 1 0
    0 1 1
    0 1
    0


    2楼2006-10-30 17:46
    回复
      • 61.186.207.*
      var
       f:array[0..101,0..101]of boolean;
       st:array[0..101,0..101]of integer;
       i,j,ax,bx,ay,by,n,t:integer;
       chr:char;

      procedure still(a,b,j:integer);
      begin
       if (f[a+1,b]=true)and(st[a+1,b]>j)then begin st[a+1,b]:=j;still(a+1,b,j+1);end;
       if (f[a-1,b]=true)and(st[a-1,b]>j)then begin st[a-1,b]:=j;still(a-1,b,j+1);end;
       if (f[a,b+1]=true)and(st[a,b+1]>j)then begin st[a,b+1]:=j;still(a,b+1,j+1);end;
       if (f[a,b-1]=true)and(st[a,b-1]>j)then begin st[a,b-1]:=j;still(a,b-1,j+1);end;
      end;



      function catch(i:longint):longint;
      begin
       if ((ax=bx)and(abs(ay-by)=1)) or ((ay=by)and(abs(ax-bx)=1))then exit(i);
       t:=-1;
       while st[bx,by]<>i do
       begin
       inc(i);
       if f[bx-1,by]then dec(bx)
       else
       if f[bx,by+1]then inc(by)
       else
       if f[bx+1,by]then inc(bx)
       else
       if f[bx,by-1]then dec(by)
       else exit(-1);
       end;
       exit(i);
      end;
      begin
       readln(n);
       for i:=1 to n do
       BEGIN
       for j:=1 to n do
       begin
       read(chr);
       if chr='F' then begin ax:=i;bx:=j;f[i,j]:=true;end;
       if chr='J' then begin bx:=i;by:=j;f[i,j]:=true;end;
       if chr='.' then f[i,j]:=true;
       if chr='*' then f[i,j]:=false;
       end;
       readln;
       end;
       for i:=0 to n+1 do f[i,0]:=false;
       for i:=0 to n+1 do f[i,n+1]:=false;
       for j:=0 to n+1 do f[0,j]:=false;
       for j:=0 to n+1 do f[n+1,j]:=false;
       for i:=0 to n+1 do
       for j:=0 to n+1 do st[i,j]:=maxint;
       st[ax,bx]:=0;
       still(ax,bx,0);
       t:=catch(0);
       if t=-1 then writeln('No solution')
       else writeln(t);end.



      待修。。。。。。。。


      3楼2006-11-05 12:01
      回复
        • 61.186.207.*
        begin
         for i:=1 to 9 do read(a[i]);
         i:=1;
         while (a[i]=0)and(i<=9) do inc(i);
         if i=9 then write(a[i])
         else
         begin
         if a[i]=1 then write('x^',9-i);
         if a[i]=-1 then write('-x^',9-i);
         if (a[i]<-1) or (a[i]>1) then write(a[i],'x^',9-i);
         end;
         inc(i);
         while i<9 do
         begin
         while (a[i]=0)and(i<9) then inc(i);
         if a[i]<-1 then write(


        4楼2006-11-05 22:01
        回复
          • 61.186.207.*
          var
           f:array[0..101,0..101]of boolean;
           st:array[0..101,0..101]of integer;
           q:array[0..3,1..2]of integer;
           i,j,ax,bx,ay,by,n,t,l:integer;
           chr:char;

          procedure still(a,b,j:integer);
          begin
           if (f[a+1,b]=true)and(st[a+1,b]>j)then begin st[a+1,b]:=j;still(a+1,b,j+1);end;
           if (f[a-1,b]=true)and(st[a-1,b]>j)then begin st[a-1,b]:=j;still(a-1,b,j+1);end;
           if (f[a,b+1]=true)and(st[a,b+1]>j)then begin st[a,b+1]:=j;still(a,b+1,j+1);end;
           if (f[a,b-1]=true)and(st[a,b-1]>j)then begin st[a,b-1]:=j;still(a,b-1,j+1);end;
          end;



          function catch(i:longint):longint;
          begin
           if ((ax=bx)and(abs(ay-by)=1)) or ((ay=by)and(abs(ax-bx)=1))then exit(i);
           if st[bx,by]=maxint then exit(-1)
           else
           begin
           while st[bx,by]>i do
           begin
           inc(i);
           while not(f[bx+q[l,1],by+q[l,2]]) do begin inc(l);l:=l mod 4;end;
           bx:=bx+q[l,1];by:=by+q[l,2];
           end;
           end;
           exit(i);
          end;
          begin
           q[0,1]:=-1;q[0,2]:=0;
           q[1,1]:=0;q[1,2]:=1;
           q[2,1]:=1;q[2,2]:=0;
           q[3,1]:=0;q[3,2]:=-1;
           readln(n);
           for i:=1 to n do
           BEGIN
           for j:=1 to n do
           begin
           read(chr);
           if chr='F' then begin ax:=i;bx:=j;f[i,j]:=true;end;
           if chr='J' then begin bx:=i;by:=j;f[i,j]:=true;end;
           if chr='.' then f[i,j]:=true;
           if chr='*' then f[i,j]:=false;
           end;
           readln;
           end;
           for i:=0 to n+1 do f[i,0]:=false;
           for i:=0 to n+1 do f[i,n+1]:=false;
           for j:=0 to n+1 do f[0,j]:=false;
           for j:=0 to n+1 do f[n+1,j]:=false;
           for i:=0 to n+1 do
           for j:=0 to n+1 do st[i,j]:=maxint;
           st[ax,bx]:=0;
           still(ax,bx,0);
           l:=0;
           t:=catch(0);
           if t=-1 then writeln('No solution')
           else writeln(t);
           end.






          var
           a:array[1..9]of integer;
           i:integer;


          begin
           for i:=1 to 9 do read(a[i]);
           i:=1;
           while (a[i]=0)and(i<9) do inc(i);
           if i=9 then write(a[i])
           else
           begin
           if a[i]=1 then write('x^',9-i);
           if a[i]=-1 then write('-x^',9-i);
           if (a[i]<-1) or (a[i]>1) then write(a[i],'x^',9-i);
           end;
           inc(i);
           while i<9 do
           begin
           while (a[i]=0)and(i<9) do inc(i);
           if a[i]<-1 then write(' - ',0-a[i],'x^',9-i);
           if a[i]=-1 then write(' - ','x^',9-i);
           if a[i]=1 then write(' + ','x^',9-i);
           if a[i]>1 then write(' + ',a[i],'x^',9-i);
           inc(i);
           end;
           if a[9]<>0 then begin
           if a[9]<0 then write(' - ',0-a[9]);
           if a[9]>0 then write(' + ',a[9]);
           end;
           writeln;
          end.


          5楼2006-11-06 09:43
          回复
            • 61.186.207.*
            var 
             a:array[1..9]of integer; 
             i:integer; 
             t:boolean;

            begin 
            t:=false;
             for i:=1 to 9 do read(a[i]); 
             i:=1; 
             while (a[i]=0)and(i<9) do inc(i); 
             if i=9 then begin write(a[i]);t:=true;end 
             else 
             begin 
             if a[i]=1 then write('x^',9-i); 
             if a[i]=-1 then write('-x^',9-i); 
             if (a[i]<-1) or (a[i]>1) then write(a[i],'x^',9-i); 
             end; 
             inc(i); 
             while i<9 do 
             begin 
             while (a[i]=0)and(i<9) do inc(i); 
             if a[i]<-1 then write(' - ',0-a[i],'x^',9-i); 
             if a[i]=-1 then write(' - ','x^',9-i); 
             if a[i]=1 then write(' + ','x^',9-i); 
             if a[i]>1 then write(' + ',a[i],'x^',9-i); 
             inc(i); 
             end; 
             if (a[9]<>0)and(t=false) then begin 
             if a[9]<0 then write(' - ',0-a[9]); 
             if a[9]>0 then write(' + ',a[9]); 
             end; 
             writeln; 
            end.


            6楼2006-11-06 09:48
            回复
              • 61.186.207.*
              var
               f:array[0..101,0..101]of boolean;
               st:array[0..101,0..101]of LONGINT;
               q:array[0..3,1..2]of longint;
               i,j,ax,bx,ay,by,n,t,l:longint;
               chr:char;
              procedure inof;
              begin
               for i:=1 to n do
               begin
               for j:=1 to n do
               begin
               read(chr);
               if chr='F' then begin ax:=i;ay:=j;f[i,j]:=true;end;
               if chr='J' then begin bx:=i;by:=j;f[i,j]:=true;end;
               if chr='.' then f[i,j]:=true;
               if chr='*' then f[i,j]:=false;
               end;
               readln;
               end;
               end;

              procedure still(a,b,j:longint);
              begin
               if (f[a+1,b]=true)and(st[a+1,b]>j)then begin st[a+1,b]:=j;still(a+1,b,j+1);end;
               if (f[a-1,b]=true)and(st[a-1,b]>j)then begin st[a-1,b]:=j;still(a-1,b,j+1);end;
               if (f[a,b+1]=true)and(st[a,b+1]>j)then begin st[a,b+1]:=j;still(a,b+1,j+1);end;
               if (f[a,b-1]=true)and(st[a,b-1]>j)then begin st[a,b-1]:=j;still(a,b-1,j+1);end;
              end;



              function catch(i:longint):longint;
              begin
               if ((ax=bx)and(abs(ay-by)=1)) or ((ay=by)and(abs(ax-bx)=1))then exit(i);
               if st[bx,by]=maxint then exit(-1)
               else
               begin
               while st[bx,by]>i do
               begin
               inc(i);
               while not(f[bx+q[l,1],by+q[l,2]]) do begin inc(l);l:=l mod 4;end;
               bx:=bx+q[l,1];by:=by+q[l,2];
               end;
               end;
               exit(i);
              end;
              begin
               assign(input,'maze9.in');
               reset(input);
               q[0,1]:=-1;q[0,2]:=0;
               q[1,1]:=0;q[1,2]:=1;
               q[2,1]:=1;q[2,2]:=0;
               q[3,1]:=0;q[3,2]:=-1;
               readln(n);
               inof;
               for i:=0 to n+1 do f[i,0]:=false;
               for i:=0 to n+1 do f[i,n+1]:=false;
               for j:=0 to n+1 do f[0,j]:=false;
               for j:=0 to n+1 do f[n+1,j]:=false;
               for i:=0 to n+1 do for j:=0 to n+1 do st[i,j]:=maxint;
               st[ax,ay]:=0;
               still(ax,ay,0);
               l:=0;
               t:=catch(0);
               if t=-1 then writeln('No solution.')
               else writeln(t);
               close(input);
               end.


              7楼2006-11-06 15:31
              回复
                • 61.186.207.*
                var
                 n,a,b,c,count,i,j:integer;
                 p,p1,d:array[0..1000]of integer;
                 s:array[0..1000,0..1000,1..2]of integer;

                procedure work(x:integer);
                var i:integer;
                begin
                 for i:=1 to d[x] do
                 begin
                 work(s[x,i,1]);work(s[x,i,2]);
                 if p[s[x,i,1]]+p[s[x,i,2]]<p[x] then p[x]:=p[s[x,i,1]]+p[s[x,i,2]];

                 end;
                end;
                procedure search(x:integer);
                begin
                 for i:=1 to d[x] do
                 begin
                 search(s[x,i,1]);search(s[x,i,2]);



                begin
                 readln(n);
                 for i:=0 to n-1 do read(p[i]);
                 p1:=p;
                 while not(seekeof) do
                 begin
                 readln(a,b,c);
                 j:=1;
                 while s[c,j,1]<>0 do inc(j);
                 s[c,j,1]:=a;s[c,j,2]:=b;inc(d[c]);
                 end;
                 count:=0;
                 work(0);
                 write(p[0]);
                 search(0);
                end.


                8楼2006-11-07 21:56
                回复
                  • 61.186.207.*
                  procedure quicksort(l,r:longint);
                  begin
                   head:=l;tail:=r;
                   t:=(l+r)div 2;f:=a[t];
                   while head<tail do
                   begin
                   while (head<tail)and((a[head].w>f.w)or(a[head].w=f.w)and(a[head].i<f.i) do inc(head);
                   while (head<tail)and((a[tail].w<f.w)or(a[tail].w=f.w)and(a[tail].i>f.i) do inc(head);
                   h:=a[head];a[head]:=a[tail];a[tail]:=h;
                   end;
                   if

                  begin
                   readln(n,k);
                   for i:=1 to 10 do read(e[i]);
                   for i:=1 to n do begin read(a[i].w);a[i].i:=i;end;
                   quicksort(1,n);
                   for i:=1 to n do begin c[i]:=(i-1)mod 10+1;a[i].w:=a[i].w+e[c[i]];end;
                   quicksort(1,n);
                   for i:=1 to k do write(a[i].i,' ');
                  end.


                  9楼2006-11-08 22:21
                  回复
                    • 61.186.207.*
                    var
                     n,i,k:integer;
                     a:array[1..100]of integer;
                    function qsort(l,r,k:integer):integer;
                    var head,tail,f,t:integer;
                    begin
                     head:=l;tail:=r;
                     t:=random(r-l+1)+l;
                     f:=a[t];
                     a[t]:=a[l];
                     while head<tail do
                     begin
                     while (head<tail)and(a[tail]>=f) do dec(tail);
                     a[head]:=a[tail];
                     while (head<tail)and(a[head]<=f) do inc(head);
                     a[tail]:=a[head];
                     end;
                     a[head]:=f;
                     if head=k then exit(a[k]);
                     if (head-1>l) and (k<head) then qsort(l,head-1,k);
                     if (head+1<r) and (k>head) then qsort(head+1,r,k);
                    end;

                    begin
                     readln(n);
                     for i:=1 to n do read(a[i]);
                     randomize;
                     readln(k);
                     writeln(qsort(1,n,k));
                    // for i:=1 to n do write(a[i],' ');
                    end.


                    10楼2006-11-13 11:31
                    回复
                      • 61.186.207.*
                      「―――Nobody lives.〈这里,没有生命。〉」

                      「There is no saving in the wide world.〈广阔的世界,无法拯救。〉」

                      「No beginning, and no ending.〈没有起始,也没有完结。〉」

                      「Filled with death, only destruction remained.〈满溢的死亡之中,残留的只有毁灭。〉」

                      「...Simply, everything withers and goes. 〈...只有,乾枯的万物。〉」


                      11楼2006-11-13 13:02
                      回复
                        • 61.186.207.*
                        「There's nothing but one——〈存在於那边的,只有一个———〉 "Dryness garden〈终结的世界〉″


                        12楼2006-11-13 13:03
                        回复
                          • 61.186.207.*
                          type
                           tt=record
                           i,j,c:integer;
                           shu:array[1..9] of integer;
                           end;

                          function left:integer;
                          var i,j,co:integer;
                          begin
                           co:=0;
                           for i:=1 to 9 do
                           for j:=1 to 9 do
                           if a[i,j]:=0 then inc(co);
                           exit(co);
                          end;

                          procedure findof(var t1:tt);
                          begin
                           min:=11;
                           for i:=1 to 9 do
                           for j:=1 to 9 do
                           if a[i,j]=0 then
                           begin
                           x:=number(i,j);
                           if x<min then begin min:=x;mini:=i;minj:=j;end;
                           end;
                           t1.i:=mini;
                           t1.j:=minj;
                           ti.x:=min;
                           for i:=1 to min do cnt[i]:=
                          end;




                          procedure search;
                          var t1:tt;
                          begin
                           if left()=0 then begin print;halt;end;
                           findof(t1);
                           if t1.x=0 then exit;
                           for i:=1 to t1.x do
                           begin
                           a[,]:=cnt[i];
                           search;
                           a[,]:=0;
                           end;
                          end;



                          begin
                           for i:=1 to 9 do
                           for j:=1 to 9 do
                           read(a[i,j]);
                           search;


                          13楼2007-02-01 11:36
                          回复
                            • 61.186.207.*
                            type
                             tt=record
                             i,j,x:integer;
                             cnt:array[1..9] of integer;
                             end;
                            var
                             i,j:integer;
                             a:array[1..9,1..9]of integer;t2:array[1..9]of integer;


                            function left:integer;
                            var i,j,co:integer;
                            begin
                             co:=0;
                             for i:=1 to 9 do
                             for j:=1 to 9 do
                             if a[i,j]=0 then inc(co);
                             exit(co);
                            end;


                            function number(i,j:integer):integer;
                            var k,l,f,si,sj:integer;c:array[1..9]of integer;
                            begin
                             f:=0;fillchar(t2,sizeof(t2),0);
                             for k:=1 to 9 do c[k]:=k;
                             for k:=1 to 9 do if a[k,j]<>0 then c[a[k,j]]:=0;
                             for k:=1 to 9 do if a[i,k]<>0 then c[a[i,k]]:=0;
                             si:=3*(i div 3)+1;
                             sj:=3*(j div 3)+1;
                             for k:=si to si+2 do
                             for l:=sj to sj+2 do
                             if a[k,l]<>0 then c[a[k,l]]:=0;
                             for k:=1 to 9 do if c[k]<>0 then begin inc(f);t2[f]:=c[k];end;
                             exit(f);
                            end;


                            procedure findof(var t1:tt);
                            var min,mini,minj,x:integer;
                            begin
                             min:=11;
                             for i:=1 to 9 do
                             for j:=1 to 9 do
                             if a[i,j]=0 then
                             begin
                             x:=number(i,j);
                             if x<min then begin min:=x;mini:=i;minj:=j;t1.cnt:=t2;end;
                             end;
                             t1.i:=mini;
                             t1.j:=minj;
                             t1.x:=min;
                            end;


                            procedure print;
                            var i,j:integer;
                            begin
                             for i:=1 to 9 do
                             begin
                             for j:=1 to 9 do write(a[i,j]);
                             writeln;
                             end;
                            end;


                            procedure search;
                            var t1:tt;i:integer;
                            begin
                             if left()=0 then begin print;halt;end;
                             findof(t1);
                             if t1.x=0 then exit;
                             for i:=1 to t1.x do
                             begin
                             a[t1.i,t1.j]:=t1.cnt[i];
                             search;
                             a[t1.x,t1.j]:=0;
                             end;
                            end;



                            begin
                             for i:=1 to 9 do
                             for j:=1 to 9 do
                             read(a[i,j]);
                             search;
                            end.


                            14楼2007-02-01 15:57
                            回复
                              • 61.186.207.*
                              type
                               tt=record
                               i,j,x:integer;
                               cnt:array[1..9] of integer;
                               end;
                              var
                               i,j:integer;
                               a:array[1..9,1..9]of integer;t2:array[1..9]of integer;


                              function left:integer;
                              var i,j,co:integer;
                              begin
                               co:=0;
                               for i:=1 to 9 do
                               for j:=1 to 9 do if a[i,j]=0 then inc(co);
                               exit(co);
                              end;


                              function number(i,j:integer):integer;
                              var k,l,f,si,sj:integer;c:array[1..9]of integer;
                              begin
                               f:=0;fillchar(t2,sizeof(t2),0);
                               for k:=1 to 9 do c[k]:=k;
                               for k:=1 to 9 do if a[k,j]<>0 then c[a[k,j]]:=0;
                               for k:=1 to 9 do if a[i,k]<>0 then c[a[i,k]]:=0;
                               si:=3*((i-1) div 3)+1;
                               sj:=3*((j-1) div 3)+1;
                               for k:=si to si+2 do
                               for l:=sj to sj+2 do
                               if a[k,l]<>0 then c[a[k,l]]:=0;
                               for k:=1 to 9 do if c[k]<>0 then begin inc(f);t2[f]:=c[k];end;
                               exit(f);
                              end;


                              procedure findof(var t1:tt);
                              var x:integer;
                              begin
                               t1.x:=11;
                               for i:=1 to 9 do
                               for j:=1 to 9 do
                               if a[i,j]=0 then
                               begin
                               x:=number(i,j);
                               if x<t1.x then begin t1.x:=x;t1.i:=i;t1.j:=j;t1.cnt:=t2;end;
                               end;
                              end;


                              procedure print;
                              var i,j:integer;
                              begin
                               for i:=1 to 9 do
                               begin
                               for j:=1 to 9 do write(a[i,j]);
                               writeln;
                               end;
                              end;


                              procedure search;
                              var t1:tt;i:integer;
                              begin
                               if left()=0 then begin print;halt;end;
                               findof(t1);
                               if t1.x=0 then exit;
                               for i:=1 to t1.x do
                               begin
                               a[t1.i,t1.j]:=t1.cnt[i];
                               search;
                               a[t1.x,t1.j]:=0;
                               end;
                              end;



                              begin
                               for i:=1 to 9 do
                               for j:=1 to 9 do read(a[i,j]);
                               search;
                              end.


                              15楼2007-02-01 16:41
                              回复