Skip to content

Instantly share code, notes, and snippets.

@aa-ahmed-aa
Created March 12, 2016 21:37
Show Gist options
  • Save aa-ahmed-aa/181e200be2bce4457480 to your computer and use it in GitHub Desktop.
Save aa-ahmed-aa/181e200be2bce4457480 to your computer and use it in GitHub Desktop.
# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
using namespace std;
int min_size(vector<vector<int>> asd)
{
vector<int> a;
a.push_back(asd[0].size());
a.push_back(asd[1].size());
a.push_back(asd[2].size());
sort(a.begin(), a.begin() + a.size());
return a[0];
}
int main()
{
vector<vector<int>> asd(3);
int n, temp;
vector<int> numbers;
cin >> n;
while (n--)
{
cin >> temp;
numbers.push_back(temp);
}
for (int i = numbers.size() - 1; i >= 0; i--)
{
if (numbers[i] == 1)
asd[0].push_back(i);
if (numbers[i] == 2)
asd[1].push_back(i);
if (numbers[i] == 3)
asd[2].push_back(i);
}
int min = min_size(asd);
cout << min << endl;
for (int i = 0; i < min; i++)
{
cout << asd[0][i] + 1<<" " << asd[1][i] + 1<<" " << asd[2][i] + 1 << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment