HDU 3635 Dragon bils (with permission and query set), hdu3635

Source: Internet
Author: User

HDU 3635 Dragon bils (with permission and query set), hdu3635

Address: HDU 3635

Weighting and checking the questions.

Use the num array to maintain the number of Dragon beads in the city, and use the times array to maintain how many times each Dragon Ball has been transported. The num array is maintained during merging. The times array is different from each other, so it is necessary to recursively maintain it all when finding the root.

In the end, the city where x Dragon Ball is located is the root of x node, and the num array value of x node is the number of Dragon beads in the city. Times [x] indicates how many times the Dragon Ball was shipped.

The Code is as follows:

#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL long longint bin[20000], num[20000], times[20000];int find1(int x){    int y;    if(bin[x]!=x)    {        y=bin[x];        bin[x]=find1(bin[x]);        times[x]+=times[y];    }    return bin[x];}void join(int x, int y){    int f1=find1(x);    int f2=find1(y);    if(f1!=f2)    {        bin[f1]=f2;        num[f2]+=num[f1];        times[f1]++;    }}int main(){    int t, nn=0, n, m, i, a, b, f;    char c;    scanf("%d",&t);    while(t--)    {        nn++;        scanf("%d%d",&n,&m);        for(i=1; i<=n; i++)        {            bin[i]=i;            num[i]=1;            times[i]=0;        }        printf("Case %d:\n",nn);        while(m--)        {            getchar();            scanf("%c",&c);            if(c=='T')            {                scanf("%d%d",&a,&b);                join(a,b);            }            else            {                scanf("%d",&a);                f=find1(a);                printf("%d %d %d\n",f,num[f],times[a]);            }        }    }    return 0;}



HDU3635 Dragon bils, the hero, help me to see why the code is always Wrong

Return ancex; the ancex in Sfind should be ancestor [x];

The younger brother wants to know that those questions on hang Dian hdu are only checked and checked. I want to train cainiao. I hope it is best to list the general difficulty levels. Thank you.

List all I know ..
Simple and query set
1213 How Many Tables
1232 smooth Engineering
(Hangdian does not have many simple query sets)

Simple minimal spanning tree
1233 or smooth Engineering
1863 smooth Engineering
1874 smooth project resumption
1875 continue smooth Engineering
1162 Eddy's picture
1102 Constructing Roads
1301 Jungle roanalyticdb
(You can use the minimum spanning tree function to perform exercises and query sets)

A little difficult and query set
1272 xiaoxi's maze
1325 Is It A Tree?
1856 More is better

Difficult to query
1116 Play on Words
1829A Bug's Life
1198 Farm Irrigation
3635 Dragon bils
2473Junk-Mail Filter
3172 Virtual Friends
3047 Zjnu Stadium
3038How Many Answers Are Wrong
1558 Segment set
1598 find the most comfortable road
3461 Code Lock
2818 Building Block
3367 false
3234Exclusive-OR

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.