The Informatics Teacher's Ambition
InterviewTime limit2sMemory limit1024 MB
Pick two of the five weekdays so that the most students can attend both lecture days, then print that count and the chosen schedule.
- Level
Easy2 of 10
- Topics
- Brute force, Implementation
- Solved
- No attempts yet
Problem
Park Sangjin, the informatics teacher at Songdo High School, wants to make Songdo a well-known school that anyone who likes coding wants to attend.
To do this, Park Sangjin plans to hold an algorithm lecture twice a week. There are students who want to take the lecture. Each student submitted, for each day from Monday to Friday, whether they can attend class that day. A student can take the lecture only if they can attend both lecture sessions.
Help Park Sangjin choose the lecture schedule so that as many students as possible can take the lecture. Write a program that finds this schedule.
Input
The first line contains the number of students who want to take the algorithm lecture.
From the second line through line , line contains five integers , separated by spaces, which describe whether student can attend each day. Each integer is or . The values are listed from Monday to Friday. A value of means student can attend that day, and means they cannot.
Output
Print the maximum number of students who can take the lecture on the first line.
On the second line, print five integers separated by spaces. Each integer is or , and exactly three of them are and exactly two are . The values are listed from Monday to Friday. A value of means the lecture is held that day, and means it is not. The schedule you print must allow the maximum number of students to take the lecture. If several schedules work, print any of them.
Constraints
.
For , is or .