Modified DSU
Complexity
Time complexity: req*rest*log(people)

Space complexity: O(people)
Code
# Complexity
- Time complexity: req\*rest\*log(people)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(people)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    vector<bool> friendRequests(int n, vector<vector<int>>& restrictions, vector<vector<int>>& requests) {
        vector<int> parent(n, -1);
        function<int(int)> findP= [&](int a) -> int{
            if(parent[a]<0)
                return a;
            return parent[a]= findP(parent[a]);
        };

        function<bool(int, int)> unionP= [&](int a, int b) -> bool{
            int pa= findP(a);
            int pb= findP(b);
            if(pa== pb)
                return true;
            for(auto rest: restrictions){
                int pc= findP(rest[0]);
                int pd= findP(rest[1]);
                if((pc== pa && pd== pb)||(pc== pb && pd== pa))
                    return false;
            }
            if(abs(parent[pa])>=abs(parent[pb])){
                parent[pa]+= parent[pb];
                parent[pb]= pa;
            }
            else{
                parent[pb]+= parent[pa];
                parent[pa]= pb;
            }
            return true;
        };
        
        vector<bool> ans;
        for(auto r: requests)
            ans.push_back(unionP(r[0], r[1]));
        return ans;
    }
};
```
['C++']