用的树状数组 但只过了3个点其他超时 求大神解答

const
maxnum=100000;
var
n,k,m,p,i,j:longint;
c:char;
dasz,dat:array[0..maxnum] of longint;

function hslowbit(x:longint):longint;
begin
exit(x and (-x));
end;
function hsqiuhe(xi:longint):longint;
var
ptem:longint;
begin
ptem:=0;
while (xi>0) do
begin
inc(ptem,dasz[xi]);
dec(xi,hslowbit(xi));
end;
exit(ptem);
end;

procedure gccharu(xi,xx:longint);
begin
while (xi<=n) do
begin
inc(dasz[xi],xx);
inc(xi,hslowbit(xi));
end;
end;

begin
assign(input,'vjp1320.in');
reset(input);
assign(output,'vjp1320.out');
rewrite(output);
fillchar(dasz,sizeof(dasz),0);
readln(n,k);
for i:=1 to k do
begin
read(c);
read(m);
case (c) of
'A':begin
writeln(hsqiuhe(m));
readln;
end;
'B':begin
readln(p);
gccharu(m,p);
end;
'C':begin
readln(p);
gccharu(m,-p);
end;
end;
end;
close(input);
close(output);
end.

1 条评论

  • @ 2014-11-05 10:41:04

    为什么要用这么厉害的东西→ → 不是一个一维数组模拟就好了么

  • 1

信息

ID
1320
难度
6
分类
模拟 点击显示
标签
(无)
递交数
2166
已通过
573
通过率
26%
被复制
6
上传者