Dislikes and Party
Practice
3.8 (71 votes)
Basic math
Algorithms
Math basic
Math
Problem
88% Success 14276 Attempts 10 Points 5s Time Limit 256MB Memory 1024 KB Max Code
You have organized a party and invited other \(N-1\) friends to the party. Therefore, there are total \(N\) friends. Everyone must shake hands with every other person except the people he or she dislikes. There are only 10 people at the party who dislike the other 9 people. The remaining people like everyone who is present at the party. Each friend has its own unique identity number.
Two friends shake hands only if both like each other. In other words, if any of them dislike others, then they cannot shake hands. You must calculate the number of handshakes done at the party.
Input format
- The first line contains a single integer \(N\) (\(10 \le N \le 10^9\)).
- The next 10 lines contain 10 integers each. The first integer in a line represents the unique identity of a friend and the other 9 integers represent the identity number of people it dislikes.
Output format
Print a single integer denoting the total number of handshakes.
Submissions
Please login to view your submissions
Similar Problems
Points:10
5 votes
Tags:
Math BasicAlgorithmsBasic MathMath
Points:10
17 votes
Tags:
MathematicsBasic MathMath
3.King Duo
Points:10
1 votes
Tags:
Basic MathAlgorithmsMath
Editorial