Advertisement
dimon-torchila

Untitled

Dec 4th, 2022
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <vector>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. void print(vector<pair<int, int>> v){
  9. for(const auto& x : v)
  10. cout << x.first << ' ' << x.second << endl;
  11. }
  12.  
  13. int main(){
  14. int ZeliyaCount;
  15. cin >> ZeliyaCount;
  16. vector<pair<int, int>> Zeliya(ZeliyaCount, {0, 0});
  17.  
  18. Zeliya[0] = {1, 0};
  19. Zeliya[1] = {0, 1};
  20.  
  21. for(int i = 2; i < Zeliya.size(); ++i){
  22. int CompCount;
  23. cin >> CompCount;
  24. for(int j = 0; j < CompCount; ++j){
  25. int component;
  26. cin >> component;
  27. if(!(Zeliya[component - 1].first == 0 && Zeliya[component - 1].second == 0)) {
  28. Zeliya[i].first += Zeliya[component - 1].first;
  29. Zeliya[i].second += Zeliya[component - 1].second;
  30. } else {
  31. Zeliya[i] = {0, 0};
  32. break;
  33. }
  34. }
  35. }
  36. print(Zeliya);
  37. int ansCount;
  38. cin >>ansCount;
  39. for(int i = 0; i < ansCount; ++i){
  40. int Acount, Bcount, Zelie;
  41. cin >> Acount >> Bcount >> Zelie;
  42. pair<int, int> zel = Zeliya[Zelie - 1];
  43. if(!(zel.first == 0 && zel.second == 0) && (zel.first <= Acount && zel.second <= Bcount))
  44. cout << 1;
  45. else cout << 0;
  46. }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement