因为每个点的(xi,yi)里面,
0<=xi,yi<=10
则,开一个d[11][11][11]的数组统计每个点出现的次数;
最多只会有11^3个点;
则暴力枚举第一个教室的点(x0,y0,z0);
枚举第二个教室的点(x1,y1,z1);
设x为这两个点的距离
是相同的点的话
dis[x]+=
是不同的点的话
dis[x]+=
把dis数组搞一个前缀和
我每个点都是从0..11枚举;
所以肯定会重一次的
最后对于每个询问r输出
1
又是忘记初始化。
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 12;
int n,q;
LL d[N][N][N];
LL dis[10000];
int main(){
//freopen("F:\rush.txt","r",stdin);
int T;
scanf("%d",&T);
while (T--){
rep1(i,0,10)
rep1(j,0,10)
rep1(k,0,10)
d[i][j][k] = 0;
rep1(i,0,9999) dis[i] = 0;
scanf("%d%d",&n,&q);
rep1(i,1,n){
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
d[x][y][z]++;
}
int ma = 0;
rep1(x0,0,10)
rep1(y0,0,10)
rep1(z0,0,10)
rep1(x1,0,10)
rep1(y1,0,10)
rep1(z1,0,10){
int t = abs(x0-x1)+abs(y0-y1)+abs(z0-z1);
if (x0==x1 && y0==y1 && z0==z1) {
LL temp = d[x0][y0][z0];
dis[t] += temp*(temp-1);
continue;
}
ma = max(ma,t);
dis[t]+=d[x0][y0][z0]*d[x1][y1][z1];
}
rep1(i,1,ma)
dis[i] = dis[i-1] + dis[i];
rep1(i,1,q){
int x;
cin >> x;
x = min(x,ma);
printf("%lld
",dis[x]/2);
}
}
//Open();
//Close();
return 0;
}