A. Team Olympiad
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 ti:

  • ti = 1, if the i-th child is good at programming,
  • ti = 2, if the i-th child is good at maths,
  • ti = 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 t1, t2, ..., tn(1 ≤ ti ≤ 3), where ti 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.

Examples
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 <bits/stdc++.h>
using namespace std;
int n, x, a[];
vector<int> v[];
int main ()
{
scanf("%d", &n);
for(int i=;i<n;i++)
{
scanf("%d", &x);
v[x].push_back(i+);
a[x]++;
}
x = min(a[], min(a[], a[]));
printf("%d\n", x);
for(int j=;j<x;j++)
printf("%d %d %d\n", v[][j], v[][j], v[][j]);
}

Codeforces Round #279 (Div. 2) vector的更多相关文章

  1. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  2. CodeForces Round #279 (Div.2)

    A: 题意: 有三个项目和n个学生,每个学生都擅长其中一个项目,现在要组成三个人的队伍,其中每个人恰好擅长其中一门,问能组成多少支队伍. 分析: 最多能组成的队伍的个数就是擅长项目里的最少学生. #i ...

  3. Codeforces Round #279 (Div. 2)f

    树形最大上升子序列 这里面的上生子序列logn的地方能当模板使  good #include<iostream> #include<string.h> #include< ...

  4. Codeforces Round #279 (Div. 2) C. Hacking Cypher 机智的前缀和处理

    #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #incl ...

  5. Codeforces Round #279 (Div. 2) 题解集合

    终于有场正常时间的比赛了...毛子换冬令时还正是好啊233 做了ABCD,E WA了3次最后没搞定,F不会= = 那就来说说做的题目吧= = A. Team Olympiad 水题嘛= = 就是个贪心 ...

  6. Codeforces Round #279 (Div. 2)B. Queue(构造法,数组下标的巧用)

    这道题不错,思维上不难想到规律,但是如何写出优雅的代码比较考功力. 首先第一个人的序号可以确定,那么接下来所有奇数位的序号就可以一个连一个的确定了.然后a[i].first==0时的a[i].seco ...

  7. Codeforces Round #279 (Div. 2) C. Hacking Cypher (大数取余)

    题目链接 C. Hacking Cyphertime limit per test1 secondmemory limit per test256 megabytesinputstandard inp ...

  8. Codeforces Round #279 (Div. 2) E. Restoring Increasing Sequence 二分

    E. Restoring Increasing Sequence time limit per test 1 second memory limit per test 256 megabytes in ...

  9. Codeforces Round #279 (Div. 2) C. Hacking Cypher 前缀+后缀

    C. Hacking Cypher time limit per test 1 second memory limit per test 256 megabytes input standard in ...

随机推荐

  1. php 做数学运算时结果为0的原因

    php是一种弱类型的脚本语言,一般情况下字符串型的数字可以直接参与运算. 但是当字符串开头是实体空格的时候系统会默认字符串等于0. 此问题比较隐蔽,在此记录下

  2. 深入理解Java中的final关键字

    Java中的final关键字非常重要,它可以应用于类.方法以及变量.这篇文章中我将带你看看什么是final关键字?将变量,方法和类声明为final代表了什么?使用final的好处是什么?最后也有一些使 ...

  3. Private-code MaxCounter

    No need for a double cycle: : You are given N counters, initially set to 0, and you have two possibl ...

  4. Nginx反向代理+keepalived

    环境两台LB(nginx).两台web(nginx/apache都行) 安装httpd web01 [root@web01 /]# /etc/init.d/iptables stop iptables ...

  5. poj 1192

    此题亦一眼看出算法,一次AC. 没什么好讲的,就是一个普通的树形动规. 用dp[n][0]表示n号顶点不取时的最大值,dp[n][1]表示n号顶点取时的最大值. dp[n][0]=max{dp[x][ ...

  6. 【Python基础学习六】函数

    1.创建函数 Python中函数的关键字def来定义. def fibs(num): f=[0,1] for i in range(1,num): f.append(f[-1]+f[-2]) retu ...

  7. TCP/IP三次握手和HTTP过程

    1.TCP连接 手机能够使用联网功能是因为手机底层实现了TCP/IP协议,可以使手机终端通过无线网络建立TCP连接.TCP协议可以对上层网络提供接口,使上层网络数据的传输建立在"无差别&qu ...

  8. Python验证码6位自动生成器

    Python验证码6位自动生成器

  9. linux下 chown命令

    对Document/ 目录下的所有文件与子目录执行相同的所有者变更,修改所有者为users用户组的username用户 chown -R username:users Document/ userna ...

  10. [转]MySQL 最基本的SQL语法/语句

    MySQL 最基本的SQL语法/语句,使用mysql的朋友可以参考下.   DDL-数据定义语言(Create,Alter,Drop,DECLARE) DML-数据操纵语言(Select,Delete ...