ABBYY Cup 2.0 - Easy

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
177 ABBYY Cup 2.0 - Easy FINISHED False 14400 441388823 April 21, 2012, 2 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 3000 ) C2 Party PROGRAMMING brute force dfs and similar dsu graphs 1500

To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friendship relations, and not to invite those who dislike each other. Both friendship and dislike are mutual feelings. More formally, for each invited person the following conditions should be fulfilled: all his friends should also be invited to the party; the party shouldn't have any people he dislikes; all people who are invited to the party should be connected with him by friendship either directly or through a chain of common friends of arbitrary length. We'll say that people a 1 and a p are connected through a chain of common friends if there exists a sequence of people a 2 , a 3 , ..., a p - 1 such that all pairs of people a i and a i + 1 ( 1 ≤ i < p ) are friends. Help the Beaver find the maximum number of acquaintances he can invite. The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers u i , v i — indices of people who form the i -th pair of friends. The next line contains an integer m — the number of pairs of people who dislike each other. Next m lines describe pairs of people who dislike each other in the same format as the pairs of friends were described. Each pair of people is mentioned in the input at most once . In particular, two persons cannot be friends and dislike each other at the same time. The input limitations for getting 30 points are: 2 ≤ n ≤ 14 The input limitations for getting 100 points are: 2 ≤ n ≤ 2000 Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to se

Tutorials

Submissions

No solutions yet.