这个题的数据是错的

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<climits>
#define s smt[sm]
#define sl smt[sml]
#define sr smt[smr]
#define summonm int mid=l+(r-l)/2
#define summonlr int sml=(sm<<1),smr=sml|1;
#define ll int
#define alt(cur,i,c) alter(1,left,right,max(left,p[cur][i].cox-k),min(right,p[cur][i].cox+k),p[cur][i].v*c)
using namespace std;
const int maxn=100010,inf=INT_MAX,a=1000001,maxl=2100000;
const double eps=1e-10;
int n,bes=0,maxx=0,maxy=0,minx=inf,miny=inf,k,cnt;
int up=inf,down=-1,left=inf,right=-1,ans=-1,sum;
struct hh
{
int maxs,addv;
}smt[maxl<<2];
struct poi
{
int x,y,v,cox,coy;
}po[maxl];
bool operator < (poi a,poi b)
{return a.x==b.x?a.y<b.y:a.x<b.x;}
vector<poi>p[maxl];
int read()
{
int x=0;
char c;
while((c=getchar())&&(c<'0'||c>'9'));
do x=x*10+c-'0';
while((c=getchar())&&c>='0'&&c<='9');
return x;

}
void maintain(int sm)
{
summonlr;
s.maxs=max(sl.maxs+sl.addv,sr.maxs+sr.addv);
}
void pushdown(int sm)
{
summonlr;
s.maxs+=s.addv;
sl.addv+=s.addv;
sr.addv+=s.addv;
s.addv=0;
}
void alter(int sm,int l,int r,int aiml,int aimr,int v)
{
if(aiml<=l&&r<=aimr)
{
s.addv+=v;
return;
}
summonm;summonlr;
if(aiml<=mid)
alter(sml,l,mid,aiml,aimr,v);
if(aimr>mid)
alter(smr,mid+1,r,aiml,aimr,v);
maintain(sm);
}
int query(int sm,int l,int r,int aiml,int aimr)
{
if(aiml<=l&&r<=aimr)
return s.maxs+s.addv;
pushdown(sm);
int maxs=inf;
summonm;summonlr;
if(aiml<=mid)
maxs=min(maxs,query(sml,l,mid,aiml,aimr));
if(aimr>mid)
maxs=min(maxs,query(smr,mid+1,r,aiml,aimr));
return maxs;
}
int billy()
{
int u=up,d=min(down,up+2*k);
if(d==down&&right-left<=2*k)
return sum;
for(int cur=u;cur<=d;cur++)
for(int i=0;i<p[cur].size();i++)
alt(cur,i,1);
while(d<=down)
{
int wtf=query(1,left,right,left,right);
ans=max(wtf,ans);
for(int i=0;i<p[u].size();i++)
alt(u,i,-1);
u++;d++;
for(int i=0;i<p[d].size();i++)
alt(d,i,1);
}
return ans;
}
main()
{
n=read();
k=read();
for(int i=1;i<=n;i++)
{
po[i].v=read();
po[i].x=read();
po[i].y=read()+a;
po[i].cox=po[i].x+po[i].y;
po[i].coy=po[i].y-po[i].x;
up=min(po[i].coy,up);
down=max(po[i].coy,down);
left=min(po[i].cox,left);
right=max(po[i].cox,right);
p[po[i].coy].push_back(po[i]);
sum+=po[i].v;
}
printf("%d\n",billy());
return 0;
}
bzoj上是对的。

0 条评论

目前还没有评论...

信息

难度
9
分类
(无)
标签
递交数
5
已通过
1
通过率
20%
上传者