80pts纯乱写dalao求调
查看原帖
80pts纯乱写dalao求调
1244161
jexst楼主2025/7/21 20:00
#include <bits/stdc++.h>
using namespace std;
int t, n, h, r;
struct node{
	int x, y, z;
}ar[1010];
bool dis(node a, node b, int R) {
	return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z) <= 4 * R * R;
}
bool vis[1010];
int main() {
	cin >> t;
	while (t--) {
		cin >> n >> h >> r;
		queue <int> q;
		for (int i = 1; i <= n; i++) vis[i] = 0;
		for (int i = 1; i <= n; i++) {
			cin >> ar[i].x >> ar[i].y >> ar[i].z;
			if (ar[i].z <= r) {
				q.push(i);
				vis[i] = 1; 
			}
		}
		bool flag = false;
		while (!q.empty()) {
			int j = q.front();
			q.pop(); 
			if (h - ar[j].z <= r) {
				cout << "Yes" << endl;
				flag = true;
				break; 
			} 
			for (int i = 1; i <= n; i++) {
				if (vis[i]) continue;
				if (dis(ar[j], ar[i], r)) {
					vis[i] = 1;
					q.push(i);
				}
			}
		}
		if (!flag) cout << "No" << endl;
	}
	return 0;
}

2025/7/21 20:00
加载中...