E-team Olympiad

Source: Internet
Author: User

Description

The school№0 of the capital of Berland have n children studying in it. All the children-school is gifted:some of them is good at programming, some is good at maths, others is good At PE (physical education). Hence, for each child we know value ti:

    • T I = 1, if the i-th child are good at programming,
    • T I = 2, if the i-th child are good at maths,
    • T I = 3, if the i-th child are good at PE

Each child happens to is 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 would be is composed of three children that is good at different subjects. That's, each team must has one mathematician, one programmer and one sportsman. Of course, each child can is a member of no more than one team.

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

Input

The first line contains an integer n (1≤ n ≤5000)-the number of children in the school. The second line contains n integerst1, t2, ..., tN (1≤ ti ≤ 3), where tI describes the skill of the c22>i-th child.

Output

The first line output integer w -the largest possible number of teams.

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

If No teams can is compiled, print the only line with value w equal to 0.

Sample Input

Input
7
1 3 1 3 2 1 2
Output
2
3 5 2
6 7 4
Input
4
2 1 1 2
Output
0

#include <stdio.h>inta[5500];intMinintAintb) {    intC; b<a?c=b:c=A; returnC;}voidShuchu (intA[],intJintN) {    inti,t;  for(i=0; i<j; i++)    {         for(t=0; t<n; t++)        {            if(a[t]==1) {printf ("%d", t+1); A[t]=0;  Break; }        }         for(t=0; t<n; t++)        {            if(a[t]==2) {printf ("%d", t+1); A[t]=0;  Break; }        }         for(t=0; t<n; t++)        {            if(a[t]==3) {printf ("%d\n", t+1); A[t]=0;  Break; }        }    }}intMain () {inti,j,t,n,a1,b1,c1; scanf ("%d",&N);  for(i=0; i<n; i++) {scanf ("%d",&A[i]); } A1=0; b1=0; c1=0;  for(i=0; i<n; i++)    {        if(a[i]==1) a1++; Else if(a[i]==2) b1++; Elsec1++; } J=min (a1,min (B1,C1)); if(j==0) printf ("0\n"); Elseprintf ("%d\n", J);    Shuchu (A,j,n); return 0;}

E-team Olympiad

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.