SHOW:
|
|
- or go back to the newest paste.
1 | type mas=array[0..1000,0..1000] of longint; | |
2 | - | vector=array[0..1000,0..1000] of char; |
2 | + | vector=array[0..1000,0..1000] of char; |
3 | - | var a:vector; b:mas; |
3 | + | var |
4 | - | ii,jj,i,j,n,k,f,l:longint;s:string;x,c,c1:char; |
4 | + | a:vector; |
5 | b:mas; | |
6 | ii,jj,i,j,n,k,f,l:longint; | |
7 | s:string; | |
8 | - | if aa>bb then max:=aa else max:=bb; |
8 | + | x,c,c1:char; |
9 | ||
10 | function max(aa,bb:longint):longint; | |
11 | begin | |
12 | - | readln (n); k:=0; c:='f'; |
12 | + | if aa>bb then |
13 | - | for i := 1 to n do |
13 | + | max:=aa |
14 | - | begin |
14 | + | else |
15 | max:=bb; | |
16 | - | for j := 1 to n do begin read(x);a[i,j]:=x;if x=c then k:=k+1;c:=x; |
16 | + | |
17 | - | end; readln; |
17 | + | |
18 | - | end; |
18 | + | |
19 | readln(n); | |
20 | - | readln(s); |
20 | + | for i := 1 to n do begin |
21 | for j := 1 to n do begin | |
22 | - | if n*n-1=k then |
22 | + | read(x); |
23 | - | begin |
23 | + | a[i,j]:=x; |
24 | - | f:=1; |
24 | + | end; readln; |
25 | - | for I := 1 to n do |
25 | + | |
26 | - | f:=(f*i) mod 1000003; |
26 | + | readln(s); |
27 | - | writeln(f) |
27 | + | b[1,1]:=1; |
28 | - | end else |
28 | + | |
29 | - | begin |
29 | + | for i := 1 to n do |
30 | for j := 1 to n do | |
31 | - | c:=s[1]; |
31 | + | if a[i,j]=s[i+j-1] then begin |
32 | - | c1:=s[2*n-1]; |
32 | + | b[i+1,j]:=(b[i+1,j]+b[i,j])mod 1000003; |
33 | - | if (a[1,1]<>c)or (a[n,n]<>c1) then writeln(0) ELSE |
33 | + | b[i,j+1]:=(b[i,j+1]+b[i,j])mod 1000003; |
34 | end; | |
35 | - | b[1,1]:=1; |
35 | + | |
36 | - | for I := 2 to n do |
36 | + | writeln(b[n,n] mod 1000003); |
37 | - | begin |
37 | + | |
38 | - | if (a[1,i]=s[i]) and (b[1,i-1]<>0) then b[1,i]:=1; |
38 | + |