fork download
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9. int n;
  10. cin>>n;
  11.  
  12. int ar[5005],fq[4]={0};
  13. for(int i=0; i<n ; i++){
  14. cin>>ar[i];
  15. fq[ar[i]]++;
  16. }
  17.  
  18. fq[0]=6;
  19. int min=fq[0];
  20. for(int i=0; i<4 ; i++){
  21. if(fq[i]<min)
  22. min=fq[i];
  23. }
  24.  
  25. cout<<min<<"\n";
  26.  
  27. for(int j=0; j<min ; j++){
  28. int x=0,y=0,z=0;
  29.  
  30. for(int i=1; i<=n; i++){
  31. if(ar[i-1]==1 && x==0 )
  32. {
  33. x=i;
  34. ar[i-1]=0;}
  35. else if(ar[i-1]==2 && y==0 ){
  36. y=i;
  37. ar[i-1]=0;
  38. }
  39. else if(ar[i-1]==3 && z==0 ){
  40. z=i;
  41. ar[i-1]=0;}
  42. /*if(z>0 && y>0 && x>0)
  43. break;
  44. */}
  45.  
  46. cout<<x<<" "<<y<<" "<<z;
  47.  
  48. cout<<"\n";
  49. }
  50.  
  51. return 0;
  52. }
  53.  
Success #stdin #stdout 0.01s 5544KB
stdin
Standard input is empty
stdout
0