Block, Stock and Two Smoking Galaxy Notes
InterviewTime limit1sMemory limit512 MB
Given a graph of effective pairs, pick a techlead and split the rest into singles or pairs such that every pair is an edge and each team has someone adjacent to the techlead.
- Level
Medium7 of 10
- Topics
- Graph, Greedy, Implementation, Brute force
- Solved
- No attempts yet
Problem
I decided to start a fancy new project related to cryptocurrency, deep learning, self-driving cars, and maybe mobile voice assistance (I will decide that later). I already have a team of promising software engineers, and the last thing left to do is choose a techlead among them.
All engineers except the techlead must be divided into teams of one or two engineers (recently I read the first ten pages of the book ``Agile Software Development: Programming in Pairs'' and found the described technique very useful!). For each pair of engineers I know whether they can interact effectively.
The choice of techlead and the distribution into teams is effective if every two-member team consists of two engineers who can interact effectively, and in every team there is at least one engineer who can interact effectively with the techlead.
I want you to find an appropriate company structure as fast as possible, so that our startup can make an IPO or ICO (I am not quite sure yet what that means, no time for that now), or determine that it is impossible and the world of success and glory is not for me (at least for today).
Input
The first line of input contains two integers and (, ), the number of software engineers and the number of successfully interacting pairs.
Each of the next lines contains two integers , (, ), the indices of engineers forming an effectively interacting pair.
All unordered pairs of engineers are different.
Output
Print a single word No if it is impossible to create a company structure satisfying my requirements.
Otherwise, print Yes on the first line.
On the second line print two integers , (, ), the index of the techlead and the number of teams.
Each of the next lines should contain two integers and defining a team. If the team consists of two members, and should be the indices of the engineers forming it, otherwise should be the index of the only engineer in the team and should be .
If there are multiple correct answers, print any of them.