```
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int res=0,f=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){res=(res<<1)+(res<<3)+(c^48);c=getchar();}
return res*f;
}
void write(int x)
{
if(x<0){putchar('-');x=-x;}
if(x>9)write(x/10);
putchar(x%10+'0');
}
struct Elaina
{
int l,r,val;
}t[114514<<10];
int cnt;
#define mid (l+r>>1)
struct segt
{
int rt;
void update(int root)
{
t[root].val=t[t[root].l].val+t[t[root].r].val;
}
int insert(int x,int l,int r,int root,int v)
{
if(!root)
root=++cnt;
if(l==r)
{
t[root].val+=v;
return root;
}
if(x<=mid)
t[root].l=insert(x,l,mid,t[root].l,v);
else
t[root].r=insert(x,mid+1,r,t[root].r,v);
update(root);
return root;
}
int query(int x,int y,int l,int r,int root)
{
if(!root)
return 0;
if(l>=x&&r<=y)
return t[root].val;
int res=0;
if(x<=mid)
res+=query(x,y,l,mid,t[root].l);
else
res+=query(x,y,mid+1,r,t[root].r);
return res;
}
void ins(int x,int v)
{
rt=insert(x,0,1e4,rt,v);
}
int que(int x,int y)
{
return query(x,y,0,1e4,rt);
}
}T[114514<<5];
int rt;
int insert(int x,int y,int l,int r,int root,int v)
{
if(!root)
root=++cnt;
T[root].ins(y,v);
if(l==r)
return root;
if(x<=mid)
t[root].l=insert(x,y,l,mid,t[root].l,v);
else
t[root].r=insert(x,y,mid+1,r,t[root].r,v);
return root;
}
int query(int x0,int x2,int y0,int y2,int l,int r,int root)
{
if(x0>x2) swap(x0,x2);
if(y0>y2) swap(y0,y2);
if(!root)
return 0;
if(l>=x0&&r<=x2)
return T[root].que(y0,y2);
int res=0;
if(x0<=mid)
res+=query(x0,x2,y0,y2,l,mid,t[root].l);
if(x2>mid)
res+=query(x0,x2,y0,y2,mid+1,r,t[root].r);
return res;
}
int TT;
int n,h,w;
int x[114514],y[114514],l[114514];
int px[114514],py[114514];
int val[114514];
int b[114514],ct;
int tot1,tot2;
map<int,int>ls;
int calc(int qx,int qy,int i)
{
qx=max(0,qx);
qy=max(0,qy);
int nx,ny;
nx=upper_bound(px+1,px+tot1+1,qx)-px-1;
ny=upper_bound(py+1,py+tot2+1,qy)-px-1;
// cout<<val[x[i]]<<" "<<val[y[i]]<<" "<<qx<<" "<<qy<<endl;
return query(x[i]+1,ls[px[nx]],y[i]+1,ls[py[ny]],0,1e4,rt);
}
int main()
{
TT=read();
while(TT--)
{
for(int i=1;i<=cnt;i++)
t[i].l=t[i].r=t[i].val=0;
rt=ct=cnt=0;
ls.clear();
n=read(),h=read(),w=read();
for(int i=1;i<=n;i++)
{
x[i]=read(),y[i]=read(),l[i]=read();
b[++ct]=x[i],b[++ct]=y[i];
}
sort(b+1,b+ct+1);
int tot=unique(b+1,b+ct+1)-b-1;
for(int i=1;i<=n;i++)
{
px[i]=x[i],py[i]=y[i];
int v=x[i];
x[i]=lower_bound(b+1,b+tot+1,x[i])-b;
val[x[i]]=v;
ls[v]=x[i];
v=y[i];
y[i]=lower_bound(b+1,b+tot+1,y[i])-b;
val[y[i]]=v;
ls[v]=y[i];
rt=insert(x[i],y[i],0,1e4,rt,l[i]);
}
sort(px+1,px+n+1);
sort(py+1,py+n+1);
tot1=unique(px+1,px+n+1)-px-1;
tot2=unique(py+1,py+n+1)-py-1;
int ans=0;
for(int i=1;i<=n;i++)
{
ans=max(ans,calc(val[x[i]]+h-1,val[y[i]]+w-1,i));
ans=max(ans,calc(val[x[i]]-h+1,val[y[i]]+w-1,i));
ans=max(ans,calc(val[x[i]]+h-1,val[y[i]]-w+1,i));
ans=max(ans,calc(val[x[i]]-h+1,val[y[i]]-w+1,i));
}
write(ans),puts("");
}
}
```
by Darling_zero_two @ 2024-02-23 14:42:11
啊这。。。
我康康
by trp_hy @ 2024-02-23 14:48:44
```cpp
1
4 3 3
2 1 1
2 3 1
1 2 1
3 2 1
out:3
ans:4
```
会有这种情况你看一下
by trp_hy @ 2024-02-23 14:59:41
@[Darling_zero_two](/user/754502)
by trp_hy @ 2024-02-23 14:59:53
所以角上不一定是星星
by trp_hy @ 2024-02-23 15:01:14
@[trp_hy](/user/497275) 知道了,谢谢珂朵莉学姐
by Darling_zero_two @ 2024-02-23 15:05:34