乍一看感觉好神,仔细一看数据范围……

什么水题啊,直接暴力就可以了……

 1 var map,w:array[0..1000,0..1000] of longint;
 2     v:array[0..1000,0..1000] of boolean;
 3     i,j,k,a1,a2,b1,b2,ans,n,m:longint;
 4     go:array[0..2,0..4] of longint;
 5     ff:boolean;
 6     ss:char;
 7 
 8 function max(a,b:longint):longint;
 9   begin
10     if a>b then exit(a) else exit(b);
11   end;
12 
13 procedure find(x,y:longint);
14   var i,nx,ny:longint;
15   begin
16     w[x,y]:=1;
17     for i:=1 to 4 do
18     begin
19       nx:=x+go[1,i];
20       ny:=y+go[2,i];
21       if v[nx,ny] then continue;
22       if map[nx,ny]>=map[x,y] then continue;
23       if w[nx,ny]=0 then find(nx,ny);
24       w[x,y]:=max(w[x,y],w[nx,ny]+1);
25     end;
26   end;
27 
28 begin
29   readln(n);
30   for i:=1 to n do
31   begin
32     for j:=1 to n do
33       read(map[i,j]);
34     readln;
35   end;
36   for i:=0 to n+1 do
37   begin
38     v[0,i]:=true;
39     v[i,0]:=true;
40     v[n+1,i]:=true;
41     v[i,n+1]:=true;
42   end;
43   go[1,1]:=-1;
44   go[2,2]:=1;
45   go[1,3]:=1;
46   go[2,4]:=-1;
47   readln(m);
48   ff:=true;
49   for k:=1 to m do
50   begin
51     read(ss);
52     if ss='C' then
53     begin
54       readln(a1,b1,a2);
55       map[a1,b1]:=a2;
56       ff:=true;
57     end
58     else if ss='S' then
59     begin
60       readln(a1,b1,a2,b2);
61       for i:=a1 to a2 do
62         for j:=b1 to b2 do
63           v[i,j]:=true;
64       ff:=true;
65     end
66     else if ss='B' then
67     begin
68       readln(a1,b1,a2,b2);
69       for i:=a1 to a2 do
70         for j:=b1 to b2 do
71           v[i,j]:=false;
72       ff:=true;
73     end
74     else begin
75       readln;
76       if not ff then
77       begin
78         writeln(ans);
79         continue;
80       end;
81       for i:=1 to n do
82         for j:=1 to n do w[i,j]:=0;
83       for i:=1 to n do
84         for j:=1 to n do
85           if (not v[i,j]) and (w[i,j]=0) then
86             find(i,j);
87       ans:=-maxlongint;
88       for i:=1 to n do
89         for j:=1 to n do ans:=max(ans,w[i,j]);
90       writeln(ans);
91       ff:=false;
92     end;
93   end;
94 end.
View Code

 

posted on 2014-12-19 22:14  acphile  阅读(118)  评论(0编辑  收藏  举报