提交记录 20074
提交时间 |
评测时间 |
2023-08-29 23:01:18 |
2023-08-29 23:01:27 |
#include<bits/stdc++.h>
#define ioclear std::ios::sync_with_stdio(false);std::cin.tie(nullptr);std::cout.tie(nullptr);
#define endl '\n'
#define int long long
using i64 = long long;
template<typename T>
struct DSU
{
std::vector<T> p, siz;
DSU(int n): p(n + 1), siz(n + 1, 1) {std::iota(p.begin(), p.end(), 0);}
int find(int x) {return p[x] == x ? x : p[x] = find(p[x]);}
bool same(int x, int y) {return find(x) == find(y);}
bool merge(int x, int y)
{
x = find(x), y = find(y);
if(x == y)
return false;
siz[x] += siz[y];
p[y] = x;
return true;
}
int size(int x) {return siz[find(x)];}
};
void solve()
{
int n, h, r;
std::cin >> n >> h >> r;
std::vector<i64> x(n + 1), y(n + 1), z(n + 1);
for(int i = 1;i <= n;i++)
std::cin >> x[i] >> y[i] >> z[i];
auto dis = [&](int i, int j) -> double
{
double X = x[i] - x[j], Y = y[i] - y[j], Z = z[i] - z[j];
return X * X + Y * Y + Z * Z;
};
auto checkup = [&](int pos) -> bool
{
return z[pos] + r >= h;
};
auto checkdown = [&](int pos) -> bool
{
return z[pos] - r <= 0;
};
DSU<i64> d(n);
bool flag = 0;
std::vector<int> pos, pos1;
for(int i = 1;i <= n;i++)
{
if(checkdown(i))
pos.emplace_back(i);
if(checkup(i))
pos1.emplace_back(i);
for(int j = 1;j <= i;j++)
if(dis(i, j) <= 4 * r * r)
d.merge(i, j);
}
for(auto v: pos)
for(auto u: pos1)
if(d.same(v, u))
{
flag = 1;
break;
}
if(flag)
std::cout << "Yes\n";
else
std::cout << "No\n";
return;
}
signed main()
{
#ifdef ONLINE_JUDGE
ioclear;
#endif
int t;
std::cin >> t;
while(t--)
solve();
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 40.82 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #2 | 59.16 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #3 | 54.52 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #4 | 169.25 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #5 | 8.048 ms | 92 KB | Accepted | Score: 10 | 显示更多 |
Testcase #6 | 16.08 ms | 84 KB | Accepted | Score: 10 | 显示更多 |
Testcase #7 | 31.752 ms | 92 KB | Accepted | Score: 10 | 显示更多 |
Testcase #8 | 28.531 ms | 84 KB | Accepted | Score: 10 | 显示更多 |
Testcase #9 | 33.705 ms | 84 KB | Accepted | Score: 10 | 显示更多 |
Testcase #10 | 33.81 ms | 84 KB | Accepted | Score: 10 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:29:43 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠