10317 Fans of Footbal Teams

Source: Internet
Author: User

10317 Fans of Footbal Teams

Time limit: 1000MS memory limit: 65535K
Number of submissions: 0 Number of Passes: 0

Question types: programming language: g++; Gcc

Description
Famous football teams, named AC Milan (AC Milan) and Inter Milan (inter) would have a match in GuangZhou City, which is Exciti Ng. So a lot of fans get together to watch the wonderful match. This trouble the local polices. In order to avoid a chaos caused by fans of the same teams, the police office in GuangZhou City decides to arrange the seat S of the gymnasium (gymnasium) during the match. All fans of the AC Milan seat Noth, while all fans of the Inter Milan seat south. However, the police first needs to identify which team a fan support. The present question is, given fans; Does they support a same team? You must give your judgment based on incomplete information. Assume N (n <= 10^5) Fans is currently in GuangZhou City, and numbered from 1 to N. You'll be given m (m <= 10^5) messages in sequence, which is in the following and both kinds:1. D [A] [b] where [a] and [b] is the numbers of the fans, and they support different teams. 2. A [a] [b] where [a] and [b] are the numbers of the fans. This requIres decide whether A and B support a same team.  




Input format



Output format
For each message "a [a] [b]" in each case, your program should give the judgment based on the information got before. The answers might be one of the ' support the same team. ', ' support different teams. ' and ' not sure yet. '



Input sample
5A 1 2D 1 2A 1 2D 2 4 a 1 4



Output sample
Not sure yet. Support different teams. Support the same team.



Author

Admin

Test instructions well understood, that, is to give a message that tells you which two people are in support of different teams, and then there is a query to ask whether two people are supporting the same team; the solution to this problem is a little bit of wonderful,,, is to apply the POJ 1182 (and find a classic topic, recommended also to do) the solution of the problem ... Since it is only to provide information that a certain two people support different teams, then use f[i]=k to say "I personally support the team is the same as the team supported by a person" the incident, while F[i+n]=p said f[i]=i the incident of the confrontation; The array f[i]=k here means that the person numbering I supports the event of a team, not the person numbered I! If the data were given to D 2 5, then merge f[2] and F[5+n] together, F[2+n] and f[5], because if the numbers 2 and 5 of the people support different teams, then f[2] and f[5] the opposite event [5+n] must exist simultaneously, and f[2] the opposite event F[2+n] and f[5] exist at the same time.

Monkey, put the code down here,,,,

1#include <iostream>2#include <cstdio>3#include <algorithm>4#include <cstring>5#include <cmath>6#include <cstdlib>7#include <cctype>8#include <queue>9#include <stack>Ten#include <map> One#include <vector> A#include <Set> -#include <utility> - #definell Long Long the #defineINF 0x3f3f3f3f - using namespacestd; -  - intt,n,m,temp; + intf[200500];//record Father's knot. - intFatherintU//looking for a father + { A     if(f[u]==u) at         returnu; -     returnf[u]=father (F[u]); - } - voidUniteintXintY//merging x and y two collections - { -     intTx=father (x), ty=father (y); in     if(tx!=ty) -f[ty]=TX; to } + BOOLSame (intXintY//determine if x and Y belong to the same set - { the     returnFather (x) = =father (y); * } $ intMain ()Panax Notoginseng { -     //freopen ("Input.txt", "R", stdin); thescanf"%d",&t); +      while(t--) A     { the         Charstr[3]; +         intb; -scanf"%d%d",&n,&m); $temp=2*N; $          for(intI=1; i<=temp;i++) -f[i]=i; -          while(m--) the         { -scanf"%s%d%d",str,&a,&b);Wuyi             if(str[0]=='D') the{//merging A and b+n, and B and a+n merging -Unite (a,b+n); WuUnite (A +n,b); -             } About             Else $             { -                 if(Same (a,b+N)) -printf"Support different teams.\n"); -                 Else if(Same (A, b)) Aprintf"Support the same team.\n"); +                 Else theprintf"Not sure yet.\n"); -  $             } the         } the     } the     return 0; the}

In fact, this problem can not be so silly, the same dorm with the big God told me in fact, with the structure of the data, and then add a data field to hold the first I personal opposing team set number on it can be

10317 Fans of Footbal Teams

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.