fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main()
  5. {
  6. int n;
  7. cin >> n;
  8. vector<int> arr1, arr2, arr3;
  9. for (int i = 1; i <= n; i++){
  10. int a; cin >> a;
  11. if (a == 1) arr1.push_back(i);
  12. else if (a == 2) arr2.push_back(i);
  13. else arr3.push_back(i);
  14. }
  15. int mx = min({arr1.size(), arr2.size(), arr3.size()});
  16. cout << mx << endl;
  17. for (int i = 0; i < mx; i++){
  18. cout << arr1[i] << ' ' << arr2[i] << ' ' << arr3[i] << endl;
  19. }
  20. }
  21.  
Success #stdin #stdout 0s 5272KB
stdin
Standard input is empty
stdout
0