프로그램 명: ceoi_wagons(special judge)
제한시간: 1 초
//sj 가 아직.......

Our recycling company is about to process waste that comes in railway wagons. There are N wagons waiting on the incoming railway track, and each wagon contains exactly one type of waste. Waste is processed according to one of a fixed number of settings. For each setting we are given the set of waste types that can be processed with this setting. Sadly, changing the setting is a very time-consuming operation, therefore the company uses one setting a day.

The wagons are to be processed in the order they arrive on the incoming railway track. To speed up recycling, the company has built an auxiliary track as shown on the figure below. This way, if the next wagon contains waste that cannot be processed with the current setting, then it can be moved to the auxiliary track, preceding the wagons that are already there. The next wagon to be processed is the first in row from either the incoming track or the auxiliary track. Mind that no wagon can be moved back from the auxiliary to the incoming track. The company wants to recycle as many wagons of waste as possible within the next three days. At the end of the third day the auxiliary track must be empty

Task

You are to write a program that computes settings for the three days, that allows the processing of the highest number of wagons with leaving the auxiliary track empty. If all the wagons can be processed in fewer than three days, then your program must give a solution with the smallest number of days.

입력

출력

If there are multiple solutions, your program should output only one; it does not matter which one.

입출력 예

입력

13 5 4
1 0
4 5 0
5 3 0
2 5 0
4 5 2 5 5 4 1 1 5 4 5 3 3

출력

11
2 1 4 
출처:ceoi 2012

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]