Guest User

Untitled

a guest
May 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct saber
  5. {
  6. string stone;
  7. string color;
  8. };
  9.  
  10. struct jedi
  11. {
  12. string name;
  13. string position;
  14. saber s;
  15. };
  16.  
  17. int main()
  18. {
  19. int size = 0;
  20. cin >> size;
  21.  
  22. jedi data[size];
  23.  
  24. string colors[size];
  25. int colorsQnty[size] = {0};
  26. int colorIndex = 0;
  27.  
  28. for(int i = 0; i < size; i++)
  29. {
  30. cin >> data[i].name;
  31. cin >> data[i].position;
  32. cin >> data[i].s.stone;
  33. string color;
  34. cin >> color;
  35. data[i].s.color = color;
  36.  
  37. bool exists = true;
  38. for(int j = 0; j < size; j++)
  39. {
  40. if(colors[j] != color)
  41. {
  42. exists = false;
  43. }
  44. else
  45. {
  46. exists = true;
  47. colorsQnty[j]++;
  48. j = size;
  49. }
  50. }
  51. if(exists == false)
  52. {
  53. colors[colorIndex] = color;
  54. colorsQnty[colorIndex]++;
  55. colorIndex++;
  56. }
  57. }
  58.  
  59. string position;
  60. cin >> position;
  61.  
  62. for(int n = 0; n < size; n++)
  63. {
  64. if(data[n].position != position)
  65. {
  66. string colorToRemove = data[n].s.color;
  67. for(int m = 0; m < colorIndex; m++)
  68. {
  69. if(colors[m] == colorToRemove)
  70. {
  71. colorsQnty[m]--;
  72. }
  73. }
  74. }
  75. }
  76.  
  77. for(int k = 0; k < colorIndex; k++)
  78. {
  79. cout << colors[k] << " " << colorsQnty[k] << endl;
  80. }
  81.  
  82. return 0;
  83. }
Add Comment
Please, Sign In to add comment