Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Plan a party 1 #153

Open
hamidgasmi opened this issue Apr 18, 2020 · 0 comments
Open

Plan a party 1 #153

hamidgasmi opened this issue Apr 18, 2020 · 0 comments
Assignees
Labels

Comments

@hamidgasmi
Copy link
Owner

hamidgasmi commented Apr 18, 2020

Problem Description

Task.
You’re planning a company party. You’d like to invite as many people as possible with a single constraint: No person should attend a party with his or her direct boss.
Find out what is the maximum possible number of invited people.
Print all the invited employees.

Input Format.
The 1st line contains an integer n: the number of people in the company.
Each of the next n − 1 lines describes the subordination structure. Everyone but for the CEO of the company has exactly 1 direct boss. There are no cycles: nobody can be a boss of a boss of a ... of a boss of himself. So, the subordination structure is a regular tree. Each of the n − 1 lines contains two integers u and v, and
you know that either u is the boss of v or vice versa (you don’t really need to know which one is the boss, but you can invite only one of them or none of them).

E.g. 1.:
Input:
1

Output:
1
1

E.g. 2.:
Input:
2
1 2

Output:
1
2

E.g. 3.:
Input:
5
5 4
2 3
4 2
1 2

Output:
3
1 3 5

E.g. 4.:
Input:
8
1 2
1 3
2 4
2 5
3 6
5 7
5 8

Output:
5
1 4 6 7 8

@hamidgasmi hamidgasmi self-assigned this Apr 18, 2020
hamidgasmi pushed a commit that referenced this issue Apr 18, 2020
hamidgasmi pushed a commit that referenced this issue Apr 18, 2020
hamidgasmi pushed a commit that referenced this issue Apr 29, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant