class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param S int整型vector 
     * @return int整型vector<vector<>>
     */
    vector< vector<int> >ans;
    vector<int> temp;

    vector<vector<int> > subsets(vector<int>& S) {
        dp(S, 0);
        sort(ans.begin(), ans.end());
        return ans;
    }

    void dp(vector<int>& S, int index){
        if(index == S.size()){
            ans.push_back(temp);
            return;
        }

        //不加入当前
        dp(S, index+1);

        //加入当前
        temp.push_back(S[index]);
        dp(S, index+1);
        temp.pop_back();

        return;
    }
};