p3:port
这题其实并不难
我们知道如果我们用二维数组就会爆
但如果我们用一位数组呢
我们把每条船的人存入一个一维数组里(因为sum(ki)<3*10^5 所以不会爆)
记录每条船在数组里的起始位置和终点位置 要用时取出来
队列加头指针,超过了时间弹掉
AC100
var
a,b,c,d,e,ans1,f,q1,ans:longint;
v:array[1..300005]of longint;
r:array[0..100005,1..3]of longint;
p:array[1..100005]of longint;
begin
assign(input,'port.in');reset(input);
assign(output,'port.out');rewrite(output);
readln(a);
q1:=1;
for b:=1 to a do
begin
read(d,e);
r[b,1]:=d;
r[b,2]:=e;
r[b,3]:=ans1+1;
for f:=1 to e do
read(v[ans1+f]);
readln;
ans1:=ans1+e;
end;
for b:=1 to a do
begin
if r[b,1]-r[q1,1]<86400 then
begin
for c:=r[b,3] to r[b,2]+r[b,3]-1 do
begin
if p[v[c]]=0 then inc(ans);
p[v[c]]:=p[v[c]]+1;
end;
writeln(ans);
end;
if r[b,1]-r[q1,1]>=86400 then
begin
while r[b,1]-r[q1,1]>=86400 do
begin
for c:=r[q1,3] to r[q1,2]+r[q1,3]-1 do
begin
if p[v[c]]=1 then dec(ans);
p[v[c]]:=p[v[c]]-1;
end;
inc(q1);
end;
for c:=r[b,3] to r[b,2]+r[b,3]-1 do
begin
if p[v[c]]=0 then inc(ans);
p[v[c]]:=p[v[c]]+1;
end;
writeln(ans);
end;
end;
close(input);
close(output);
end.