Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <vector>
- using namespace std;
- void print(vector<pair<int, int>> v){
- for(const auto& x : v)
- cout << x.first << ' ' << x.second << endl;
- }
- int main(){
- int ZeliyaCount;
- cin >> ZeliyaCount;
- vector<pair<int, int>> Zeliya(ZeliyaCount, {0, 0});
- Zeliya[0] = {1, 0};
- Zeliya[1] = {0, 1};
- for(int i = 2; i < Zeliya.size(); ++i){
- int CompCount;
- cin >> CompCount;
- for(int j = 0; j < CompCount; ++j){
- int component;
- cin >> component;
- if(!(Zeliya[component - 1].first == 0 && Zeliya[component - 1].second == 0)) {
- Zeliya[i].first += Zeliya[component - 1].first;
- Zeliya[i].second += Zeliya[component - 1].second;
- } else {
- Zeliya[i] = {0, 0};
- break;
- }
- }
- }
- print(Zeliya);
- int ansCount;
- cin >>ansCount;
- for(int i = 0; i < ansCount; ++i){
- int Acount, Bcount, Zelie;
- cin >> Acount >> Bcount >> Zelie;
- pair<int, int> zel = Zeliya[Zelie - 1];
- if(!(zel.first == 0 && zel.second == 0) && (zel.first <= Acount && zel.second <= Bcount))
- cout << 1;
- else cout << 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement