bzoj 3208 暴力

时间:2023-12-25 22:51:25

对于每个操作,直接暴力做就行了,询问的话搜一遍,然后

就这么水过去了。

/**************************************************************
    Problem:
    User: BLADEVIL
    Language: Pascal
    Result: Accepted
    Time: ms
    Memory: kb
****************************************************************/
 
//By BLADEVIL
var
    n, m                        :longint;
    map, w                      :array[..,..] of longint;
    flag                        :array[..,..] of boolean;
    ans                         :longint;
    go                          :array[..,..] of longint;  
     
function max(a,b:longint):longint;
begin
    if a>b then max:=a else max:=b;
end;
 
procedure find(x,y:longint);
var
    i                           :longint;
    nx, ny                      :longint;
begin
    for i:= to do
    begin
        nx:=x+go[,i];
        ny:=y+go[,i];
        if flag[nx,ny] then continue;
        if map[nx,ny]>=map[x,y] then continue;
        if w[nx,ny]= then find(nx,ny);
        w[x,y]:=max(w[x,y],w[nx,ny]+);
    end;
end;
 
procedure init;
var
    i, j                        :longint;
begin
    read(n);
    for i:= to n do
        for j:= to n do read(map[i,j]);
    fillchar(flag,sizeof(flag),false);
    for i:= to n+ do
    begin
        flag[,i]:=true;
        flag[i,]:=true;
        flag[n+,i]:=true;
        flag[i,n+]:=true;
    end;
    go[,]:=-; go[,]:=;
    go[,]:=; go[,]:=-;
end;
 
procedure main;
var
    i, j, t                     :longint;
    ss                          :char;
    x, y, z                     :longint;
    a1, b1, a2, b2              :longint;
     
begin
    readln(m);
    for t:= to m do
    begin
        read(ss);
        if ss='C' then
        begin
            readln(x,y,z);
            map[x,y]:=z;
        end else
        if ss='S' then
        begin
            readln(a1,b1,a2,b2);
            for i:=a1 to a2 do
                for j:=b1 to b2 do
                    flag[i,j]:=true;
        end else
        if ss='B' then
        begin
            readln(a1,b1,a2,b2);
            for i:=a1 to a2 do
                for j:=b1 to b2 do
                    flag[i,j]:=false;
        end else
        begin
            readln;
            for i:= to n do
                for j:= to n do w[i,j]:=;
            for i:= to n do
                for j:= to n do
                if (not flag[i,j]) and (w[i,j]=) then
                    find(i,j);
            ans:=-maxlongint;
            for i:= to n do
                for j:= to n do ans:=max(ans,w[i,j]);
            writeln(ans);
        end;
    end;
end;
 
begin
    init;
    main;
end.