提交记录 20074


用户 题目 状态 得分 用时 内存 语言 代码长度
_Dusker noip17d. 【NOIP2017】奶酪 Accepted 100 33.81 ms 92 KB C++17 1.86 KB
提交时间 评测时间
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();
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #140.82 us36 KBAcceptedScore: 10

Testcase #259.16 us36 KBAcceptedScore: 10

Testcase #354.52 us36 KBAcceptedScore: 10

Testcase #4169.25 us36 KBAcceptedScore: 10

Testcase #58.048 ms92 KBAcceptedScore: 10

Testcase #616.08 ms84 KBAcceptedScore: 10

Testcase #731.752 ms92 KBAcceptedScore: 10

Testcase #828.531 ms84 KBAcceptedScore: 10

Testcase #933.705 ms84 KBAcceptedScore: 10

Testcase #1033.81 ms84 KBAcceptedScore: 10


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:29:43 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠