Akoj-1140-League of Legends

Source: Internet
Author: User

League of Legends

Time limit:1000ms Memory limit:65536k
Total submit:54 accepted:16

Description

The land of runes-Valoran, as the largest magical continent, is the center of the heart of the Rune Land, the largest continent in the area of runes. All the forces seeking the supremacy of the runes have focused on the Valoran.
Nearly 200 years of war and strife have led to the misuse of magic, armed with spells and runes, and heroes who have created most of the magical items to lead their armies. They have an almost limitless use of primitive magical power, never considering how the endless misuse of magic will bring disaster to the environment of the continent. The last two Rune Wars affected the geological environment of Valoran. Earthquakes and magical storms make the whole valoran tremble, and for people this fear goes far beyond the horrors of war. People finally realized that the world could not afford the destruction of the Rune Wars.
In response to the worsening political and economic crisis in the world, Valoran's wizards have reached a consensus that conflicts are handled in a controlled and systematic manner. They set up an organization called the League of Heroes.
But the alliance's strife did not disappear, and the heroes of Demacia and Noxus continued to fight for their convictions.

Input

The first line has two integer n,m.
N (0 < n < 100) indicates that there are n heroes; m (0 < m < 100) indicates that there is a next m row of data.
Next M-line, each row has two integers, a, B. Represents a A/b hero in the same camp. By default, any two heroes are not in the same camp.

Output

The number of factions that output N heroes.

Sample Input

5  5

Sample Output

2

Hint

[Email protected]

Source

[Submit]   [Go back]   [Status] [Discuss]

Basic idea: The same camp gives them the same number, count is used for both counting and assigning values to the same camp

1#include <iostream>2 using namespacestd; 3 intMain () {4     intn,m,p,q,a[101]= {0},count=1; 5Cin>>n>>m;cin>>p>>Q; 6a[p]=a[q]=count; 7      for(intI=1; i<m; i++){  8Cin>>p>>Q; 9         if(a[p]!=0) a[q]=A[p]; Ten         Else{   Onecount++;  Aa[p]=count;  -a[q]=A[p];  -         }   the     }   -cout<<count<<Endl;  -     return 0;  -}

Akoj-1140-League of Legends

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.