#include <iostream>
#include <cstring>
#include <queue>
#include <list>
using namespace std;
//#define FIO
struct IO {
#ifdef FIO
const static int BUFSIZE = 1 << 20;
char buf[BUFSIZE], obuf[BUFSIZE], *p1, *p2, *pp;
inline char gc() {
return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUFSIZE, stdin), p1 == p2) ? EOF : *p1++;
}
inline void pc(char c) {
if(pp - obuf == BUFSIZE) fwrite(obuf, 1, BUFSIZE, stdout), pp = obuf;
*pp = c, pp++;
}
IO() {
p1 = buf, p2 = buf, pp = obuf;
}
~IO() {
fwrite(obuf, 1, pp - obuf, stdout);
}
#else
inline char gc() {
return getchar();
}
inline void pc(char c) {
putchar(c);
}
#endif
template<typename Tp = int>
inline Tp read() {
Tp s = 0;
int f = 1;
char ch = gc();
while(!isdigit(ch)) f = (ch == '-' ? -1 : 1), ch = gc();
while(isdigit(ch)) s = s * 10 + (ch ^ 48), ch = gc();
return s * f;
}
template<typename Tp>
void read(Tp &x) {
x = read();
}
template<typename Tp, typename... Ts>
void read(Tp &x, Ts &...val) {
x = read<Tp>();
read(val...);
}
template<typename Tp>
void write(Tp x) {
if(x < 0) pc('-'), x = -x;
static char sta[20];
int top = 0;
do sta[top++] = x % 10 + '0', x /= 10;
while(x);
while(top) pc(sta[--top]);
}
template<typename Tp, typename... Ts>
void write(Tp x, Ts... val) {
write(x);
pc(' ');
write(val...);
}
template<typename... Ts>
void writeln(Ts... val) {
write(val...);
pc('\n');
}
} io;
inline long long squ(const long long &x) {
return x * x;
}
int t, n, h, r;
struct Node {
int x, y, z;
inline bool canGoThrough(Node other) {
return (squ(x - other.x) + squ(y - other.y) + squ(z - other.z)) <= squ((long long)r << 1);
}
} nodes[1010];
list<int> edges[1010];
bool vis[1010];
queue<int> q;
inline bool bfs() {
while(q.size()) q.pop();
memset(vis, false, sizeof(vis));
for(int i = 1; i <= n; i++)
if(nodes[i].z - r <= 0) {
if(nodes[i].z + r >= h) return true;
q.push(i), vis[i] = true;
}
while(q.size()) {
int u = q.front();
q.pop();
for(int to : edges[u]) {
if(nodes[to].z + r >= h) return true;
if(!vis[to])
q.push(to), vis[to] = true;
}
}
return false;
}
void writeln(string str) {
for(char ch : str) io.pc(ch);
io.pc('\n');
}
int main() {
t = io.read();
while(t--) {
io.read(n, h, r);
for(int i = 1; i <= n; i++) edges[i].clear();
for(int i = 1; i <= n; i++) nodes[i] = {io.read(), io.read(), io.read()};
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
if(i != j && nodes[i].canGoThrough(nodes[j]))
edges[i].push_back(j);
writeln(bfs() ? "Yes" : "No");
}
//system("pause");
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 41.55 us | 64 KB | Accepted | Score: 10 | 显示更多 |
Testcase #2 | 49.34 us | 64 KB | Accepted | Score: 10 | 显示更多 |
Testcase #3 | 48.43 us | 68 KB | Accepted | Score: 10 | 显示更多 |
Testcase #4 | 66.73 us | 68 KB | Accepted | Score: 10 | 显示更多 |
Testcase #5 | 8.473 ms | 284 KB | Accepted | Score: 10 | 显示更多 |
Testcase #6 | 17.156 ms | 320 KB | Accepted | Score: 10 | 显示更多 |
Testcase #7 | 33.702 ms | 620 KB | Accepted | Score: 10 | 显示更多 |
Testcase #8 | 30.203 ms | 376 KB | Accepted | Score: 10 | 显示更多 |
Testcase #9 | 32.013 ms | 432 KB | Accepted | Score: 10 | 显示更多 |
Testcase #10 | 32.214 ms | 332 KB | Accepted | Score: 10 | 显示更多 |