CF490A.Team Olympiad

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The School №0 of the capital of Berland has nn 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 tit_{i} :

  • ti=1t_{i}=1 , if the ii -th child is good at programming,
  • ti=2t_{i}=2 , if the ii -th child is good at maths,
  • ti=3t_{i}=3 , if the ii -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?

输入格式

The School №0 of the capital of Berland has nn 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 tit_{i} :

  • ti=1t_{i}=1 , if the ii -th child is good at programming,
  • ti=2t_{i}=2 , if the ii -th child is good at maths,
  • ti=3t_{i}=3 , if the ii -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?

输出格式

In the first line output integer ww — the largest possible number of teams.

Then print ww 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 11 to nn 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 ww equal to 0.

输入输出样例

  • 输入#1

    7
    1 3 1 3 2 1 2
    

    输出#1

    2
    3 5 2
    6 7 4
    
  • 输入#2

    4
    2 1 1 2
    

    输出#2

    0
    
首页