if(islower(state[ix])) state[ix]=toupper(state[ix]);
改为
transfrom(state[ix].begin(), state[ix].end(), state[ix].begin(), toupper);