回溯算法模板 v0

def backtrack(path, state, opts):
    if base:  # 基线条件
        res.append(path)
        return
    for opt in opts:
        if prune:  # 剪枝条件
            return
        # 保存现场(做出选择)
        path.append(opt)
        state = change(state)
        opts.remove(opt)
        # 递归
        backtrack(path, state, opts)
        # 恢复现场(撤销选择)
        path.remove(opt)
        state = unchange(state)
        opts.append(opt)