Codeforces Round 279 (Div. 2)
A
Team Olympiad
Codeforces
800
原题
←B →
翻译中…

The School №0 of the capital of Berland has $*n*$ children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value $*t*_{*i*}$:

翻译中…
  • $*t*_{*i*} = 1$, if the $*i*$-th child is good at programming,
  • $*t*_{*i*} = 2$, if the $*i*$-th child is good at maths,
  • $*t*_{*i*} = 3$, if the $*i*$-th child is good at PE
翻译中…

Each child happens to be good at exactly one of these three subjects.

翻译中…

The Team Scientific Decathlon Olympias requires teams of three students. The school teachers decided that the teams will be composed of three children that are good at different subjects. That is, each team must have one mathematician, one programmer and one sportsman. Of course, each child can be a member of no more than one team.

翻译中…

What is the maximum number of teams that the school will be able to present at the Olympiad? How should the teams be formed for that?

翻译中…

Input

翻译中…

The first line contains integer $*n*$ ($1 ≤ *n* ≤ 5000$) — the number of children in the school. The second line contains $*n*$ integers $*t*_{1}, *t*_{2}, ..., *t*_{*n*}$ ($1 ≤ *t*_{*i*} ≤ 3$), where $*t*_{*i*}$ describes the skill of the $*i*$-th child.

翻译中…

Output

翻译中…

In the first line output integer $*w*$ — the largest possible number of teams.

翻译中…

Then print $*w*$ lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from $1$ to $*n*$ in the order of their appearance in the input. Each child must participate in no more than one team. If there are several solutions, print any of them.

翻译中…

If no teams can be compiled, print the only line with value $*w*$ equal to 0.

翻译中…

样例

Input #1
7
1 3 1 3 2 1 2
Output #1
2
3 5 2
6 7 4
InputCopy OutputCopy
Input #2
4
2 1 1 2
Output #2
0
InputCopy OutputCopy
题目信息
题号
490A
时间限制
1 s
内存限制
256 MB
标签
贪心
模拟
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。