[LeetCode]Course Schedule II

DFS again.
Just some little changes from the first version of the question.

struct mdata {  
    set<int> *next;
    char color;
};

class Solution {  
private:  
    vector<int> ans;
    unordered_map<int, struct mdata*> m;

    bool DFS_VISIT(int label) {
        m[label]->color = 'G';

        for(auto i: *(m[label]->next)) {
            if(m[i]->color == 'G') {
                return false;
            }
            if(m[i]->color == 'W') {
                if(DFS_VISIT(i) == false) {
                    return false;
                }
            }
        }

        ans.push_back(label);
        m[label]->color = 'B';
        return true;
    }

public:  
    vector<int> findOrder(int numCourses, vector<pair<int, int>>& prerequisites) {
        for(int i = 0; i < numCourses; i++) {
            struct mdata *pm = new struct mdata;
            pm->next = new set<int>;
            pm->color = 'W';
            m[i] = pm;
        }

        for(auto p: prerequisites) {
            m[p.first]->next->insert(p.second);
        }

        bool tmp = true;

        for(auto p: m) {
            if(p.second->color == 'W') {
                tmp &= DFS_VISIT(p.first);
            }
        }

        if(tmp) {
            return ans;
        } else {
            return vector<int>();
        }
    }
};