#C2577. Organize Registrations
Organize Registrations
Organize Registrations
You are given a list of registrations. Each registration consists of a registrant's name and a binary flag indicating whether the registrant opted for daily updates. Your task is to organize the registrations into two categories: those who opted for daily updates and those who did not.
Sort the names in each category in alphabetical order.
Input consists of an integer \(n\) (the number of registrations) followed by \(n\) lines, each containing a name and a flag (1 for opting in and 0 for opting out). Your program should output two lines: the first line containing the sorted names for those who opted in, and the second for those who did not. If there are no names in a category, output an empty line.
inputFormat
The input is read from standard input (stdin) and follows this format:
- The first line contains an integer \(n\), the number of registrations.
- The next \(n\) lines each contain a string and an integer separated by space. The string is the registrant's name, and the integer is either 1 (if the registrant opted for daily updates) or 0 (if not).
outputFormat
Output to standard output (stdout) should contain exactly two lines:
- The first line should list the names of registrants who opted for daily updates in alphabetical order, separated by a single space.
- The second line should list the names of registrants who did not opt for daily updates in alphabetical order, separated by a single space.
- If a category is empty, print an empty line.
5
Alice 1
Bob 0
Charlie 1
Dave 0
Eve 1
Alice Charlie Eve
Bob Dave
</p>