提交记录 7993


用户 题目 状态 得分 用时 内存 语言 代码长度
Jouna_Kasa_Hasinele noip17d. 【NOIP2017】奶酪 Accepted 100 26.802 ms 15724 KB C++ 1.50 KB
提交时间 评测时间
2019-01-26 21:46:02 2020-08-01 01:11:26
#include<cstdio>
#include<cstring>
#include<cmath>
typedef long long ll;
const int N=1005,M=2004005;
int t,n,h,r,tot;
struct node
{
    int x,y,z;
}nm[N];
int first[N],next[M],end[M];
bool vis[N];
inline void addedge(int u,int v)
{
    tot++;
    next[tot]=first[u];
    first[u]=tot;
    end[tot]=v;
}
inline ll dist(node a,node b)
{
    return 1ll*(a.x-b.x)*(a.x-b.x)+1ll*(a.y-b.y)*(a.y-b.y)+1ll*(a.z-b.z)*(a.z-b.z);
}
void dfs(int u)
{
    vis[u]=1;
    for(int j=first[u];j!=0;j=next[j])
        if(vis[end[j]]==0)
            dfs(end[j]);
}
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d",&n,&h,&r);
        for(int i=1;i<=n;i++)
            scanf("%d%d%d",&nm[i].x,&nm[i].y,&nm[i].z);
        tot=0;
        memset(first,0,sizeof(first));
        memset(next,0,sizeof(next));
        memset(end,0,sizeof(end));
        for(int i=1;i<=n;i++)
            for(int j=i+1;j<=n;j++)
                if(dist(nm[i],nm[j])<=4ll*r*r)
                {
                    addedge(i,j);
                    addedge(j,i);
                }
        for(int i=1;i<=n;i++)
        {
            if(h-nm[i].z<=r&&h-nm[i].z>=-r)
            {
                addedge(i,n+1);
                addedge(n+1,i);
            }
            if(nm[i].z<=r&&nm[i].z>=-r)
            {
                addedge(0,i);
                addedge(i,0);
            }
        }
        memset(vis,0,sizeof(vis));
        dfs(0);
        if(vis[n+1])
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #13.441 ms15 MB + 320 KBAcceptedScore: 10

Testcase #211.585 ms15 MB + 320 KBAcceptedScore: 10

Testcase #33.991 ms15 MB + 320 KBAcceptedScore: 10

Testcase #411.585 ms15 MB + 320 KBAcceptedScore: 10

Testcase #57.301 ms15 MB + 344 KBAcceptedScore: 10

Testcase #613.858 ms15 MB + 356 KBAcceptedScore: 10

Testcase #726.802 ms15 MB + 364 KBAcceptedScore: 10

Testcase #825.257 ms15 MB + 356 KBAcceptedScore: 10

Testcase #926.191 ms15 MB + 360 KBAcceptedScore: 10

Testcase #1026.294 ms15 MB + 360 KBAcceptedScore: 10


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