1

void recursion(string state,int pos){
    int i,ind,temp,x;
    bool flag = false;
    temp = stoi(state,nullptr,2);
    x=temp;
    if(visited[temp]) {
        return;
    }
    visited[temp]++;
    for(i = state.size()-1;i >= 0; i-- ){
        if(state[i] == '0'){
            flag = true;
            ind = state.size() - i;
            temp = temp>>ind;
            temp = temp | ICV;
            string inter = "";
            while(temp!=0){
                int x;
                x = temp%2;
                inter = to_string(x) + inter;
                temp/=2;
            }
            adj[{state,pos}].push_back(make_pair(inter,ind));
            temp = x;
            recursion(inter,ind);
        }
    }
    if(!flag){
        adj[{state,pos}].push_back(make_pair(icv,times));
    }
    visited[temp]--;
}

use of stoi() in c++?

Answered question