Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct saber
- {
- string stone;
- string color;
- };
- struct jedi
- {
- string name;
- string position;
- saber s;
- };
- int main()
- {
- int size = 0;
- cin >> size;
- jedi data[size];
- string colors[size];
- int colorsQnty[size] = {0};
- int colorIndex = 0;
- for(int i = 0; i < size; i++)
- {
- cin >> data[i].name;
- cin >> data[i].position;
- cin >> data[i].s.stone;
- string color;
- cin >> color;
- data[i].s.color = color;
- bool exists = true;
- for(int j = 0; j < size; j++)
- {
- if(colors[j] != color)
- {
- exists = false;
- }
- else
- {
- exists = true;
- colorsQnty[j]++;
- j = size;
- }
- }
- if(exists == false)
- {
- colors[colorIndex] = color;
- colorsQnty[colorIndex]++;
- colorIndex++;
- }
- }
- string position;
- cin >> position;
- for(int n = 0; n < size; n++)
- {
- if(data[n].position != position)
- {
- string colorToRemove = data[n].s.color;
- for(int m = 0; m < colorIndex; m++)
- {
- if(colors[m] == colorToRemove)
- {
- colorsQnty[m]--;
- }
- }
- }
- }
- for(int k = 0; k < colorIndex; k++)
- {
- cout << colors[k] << " " << colorsQnty[k] << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment