脑子不好使,想不明白哎

class Solution {
public:
    vector<vector<int> > permute(vector<int> &num) {
        vector<vector<int> > res;
        dfs(res, vector<int>(), vector<int>(num.size(), 0), num);
        return res;
    }

    void dfs(vector<vector<int> > &res, vector<int> tmp, vector<int> visited, vector<int> &num) {
        if (tmp.size() == num.size()) { res.push_back(tmp); return; }
        for (int i = 0; i < num.size(); ++i) {
            if (visited[i] == 1) continue;
            visited[i] = 1;
            tmp.push_back(num[i]);
            dfs(res, tmp, visited, num);
            tmp.pop_back();
            visited[i] = 0;
        }
    }
};