One, Two, Three
시간 제한2초메모리 제한1024 MB
1, 2, 3으로 이루어진 수열이 주어질 때 1-2-3 또는 3-2-1 형태의 서로 겹치지 않는 삼중항을 최대한 많이 찾아 출력한다.
문제
You are given a sequence of length : . It consists of only three kinds of integers: .
A tuple of indices is good if and it satisfies one of the two following conditions: either or .
Your goal is find disjoint good tuples, as many of them as possible. A group of tuples is disjoint if no index is present in more than one tuple.
Find the maximum number of disjoint good tuples and print each tuple.
입력
The first line contains an integer , the length of the given sequence ().
The next line contains integers: ().
출력
On the first line, print an integer , the maximum number of disjoint good tuples.
On the next lines, print the tuples themselves. Each of these lines must contains three integers () that describes a good tuple. All the printed tuples must be disjoint. If there are several solutions, print any one of them.