AcWing
  • 首页
  • 活动
  • 题库
  • 竞赛
  • 应用
  • 更多
    • 题解
    • 分享
    • 商店
    • 问答
    • 吐槽
  • App
  • 登录/注册

4266.无线网络



0


题目链接 4266.无线网络
有木有大佬帮我看看这题错哪了呜呜呜、、、就差最后一个数据没过了
错误的代码:

#include <bits/stdc++.h>
using namespace std;
const int N=1010;
int p[N],st[N];
vector<pair<int,int>>v;
int n,d;
int find(int x)
{
    if(x!=p[x])p[x]=find(p[x]);
    return p[x];
}
int main()
{
    cin>>n>>d;
    v.push_back({-1,-1});
    for(int i=1;i<=n;i++)
    {
        p[i]=i;
        int x,y;
        cin>>x>>y;
        v.push_back({x,y});
    }
    char k;
    while(cin>>k)
    {
        int a,b;
        if(k=='O')//开机
        {
            cin>>a;
            st[a]=1;
            for(int i=1;i<=n;i++)
            {
                if(st[i]==1)
                {
                    int dist=sqrt(pow(v[a].first-v[i].first,2)+pow(v[a].second-v[i].second,2));
                    if(dist<=d)p[find(a)]=find(i);
                }
            }
        }
        else
        {
            cin>>a>>b;
            a=find(a);
            b=find(b);
            if(a!=b)cout<<"FAIL"<<endl;
            else cout<<"SUCCESS"<<endl;
        }
    }
}


提问于15天前
暴躁小鳄鱼
4597


1 个问答



0

求距离的时候将int转化为double就行了

回答于14天前
不想学习啊
1695

我来回答
你确定删除吗?
1024
x

© 2018-2023 AcWing 版权所有  |  京ICP备17053197号-1
用户协议  |  隐私政策  |  常见问题  |  联系我们
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标
请输入绑定的邮箱地址
请输入注册信息