language: Pascal (fpc) (fpc 2.2.0)
date: 109 days 19 hours ago
link:
可見度: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
program Project3out;
 
 
var p:Array of array of integer;
     N,R,i,j,k,M,C,NulaX,NulaY,o,count,Res:integer;
     br,xx:boolean;
begin
 readln(N);
  for i:=1 to N do begin      //1
   Res:=2;
   br:=false;
   readln(R);
   setlength(p,R+2,R+2);
    for j:=0 to R+1 do begin //2
     for k:=0 to R+1 do begin //3
     if (k=0) or (k=R+1) or (j=0) or (j=R+1) then p[k,j]:=(R*R) else begin
      read(p[j,k]);
      if p[j,k]=0 then begin
       NulaX:=j;
       NulaY:=k;
       end;
      end;
     end;
    end;
    readln(M);
    for o:=1 to M do begin
     read(C);
     if p[NulaX,NulaY-1] = C then begin
      p[NulaX,NulaY] := C;
      dec(NulaY);
      p[NulaX,NulaY]:=0;
     end
 
     else if p[NulaX,NulaY+1] = C then begin
      p[NulaX,NulaY] := C;
      inc(NulaY);
      p[NulaX,NulaY]:=0;
     end
 
     else if p[NulaX-1,NulaY] = C then begin
      p[NulaX,NulaY] := C ;
      dec(NulaX) ;
      p[NulaX,NulaY]:=0;
     end
 
     else if p[NulaX+1,NulaY] = C then begin
      p[NulaX,NulaY] := C ;
      inc(NulaX);
      p[NulaX,NulaY]:=0;
     end
     Else begin
      res:=1;
      br:=true;
     end;
    if br=true then break;
   end;
  count:=1;
  if br=false then begin
  for j:=1 to R do
     for k:=1 to R do begin
       xx:=true;
       if j<>R then xx:=false;
       if k<>R then xx:=false;
       if p[j,k]<>0 then xx:=false;
 
       if p[j,k]=count then
       inc(count)
       else if xx<>true then res:=3;
        end;
       end;
  case res of
  1 : Writeln('Pokus o utok');
  2 : Writeln('Prihlaseny do systemu');
  3 : writeln('Cas Vyprsal')
 
  end;
  end; //1
 
 readln;
end.