Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
欢迎参加IJCAI 2020麻将智能体竞赛,大奖等你拿!Welcome to IJCAI 2020 Mahjong AI competition with amazing prizes! | 北京大学《ACM/ICPC大学生程序设计竞赛训练》暑期课面向全球招生!

Re:实践证明写递归是可以过的(907MS)

Posted by 17310320725 at 2018-07-27 16:03:39 on Problem 2236
In Reply To:Re:注意一下这题有个很奇葩的坑点... Posted by:17310320725 at 2018-07-27 16:02:26
# include<map>
# include<set>
# include<list>
# include<stack>
# include<queue>
# include<bitset>
# include<vector>
# include<string>
# include<fstream>
# include<istream>
# include<ostream>
# include<sstream>
# include<iostream>
# include<math.h>
# include<time.h>
# include<ctype.h>
# include<stdio.h>
# include<stdlib.h>
# include<string.h>
# include<algorithm>
# include<functional>



using namespace std;
const int maxx=1005;
int n,m;
int fa[maxx];
int k,l;

struct node
{
    int x,y;
    bool num;
} cool[maxx];

void init()
{
    for(int i=0; i<=n; i++)
    {
        fa[i] = i;
        cool[i].num = false;
    }
}

int Find(int x)
{
    if (x != fa[x])
        fa[x] = Find(fa[x]);
    return fa[x];
}


int leng(node a,node b)
{
    if ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)<=m*m)
        return true;
    return false;
}


void Uoion(int x)
{
    for(int i=1; i<=n; i++)
        if (cool[i].num and leng(cool[x],cool[i]))
        {
            fa[Find(x)] = Find(i);
        }
}

int main()
{
    cin>>n>>m;
    init();
    for(int i=1; i<=n; i++)
        scanf("%d%d",&cool[i].x,&cool[i].y);
    char c;
    getchar();
    while(~scanf("%c",&c))
    {
    getchar();

        if(c=='O')
        {
            scanf("%d",&k);
            cool[k].num = true;//先来标记一下我已经找到这个点
            Uoion(k);
        }
        else if (c=='S')
        {
            scanf("%d%d",&k,&l);
            if(Find(k)==Find(l))
                puts("SUCCESS");
            else
                puts("FAIL");
        }
    getchar();
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator