第五届字节青训营笔试后端编程练习题解( 二 )

< 4; ++i) {for(int j = 0,loc_len = sa[i].size();j < loc_len; ++j) {if(sa[i][j] >= '0' && sa[i][j] <= '9')sb[i][j] = sa[i][j];else {if(mp[sa[i][j]] < 0 || mp[sa[i][j]] > 9) return;sb[i][j] = char(mp[sa[i][j]] + '0');} }if(check(sb[i]) == false) return;}string loc_ss = sb[0];for(int i = 1;i < 4; ++i) {loc_ss.append(".");loc_ss.append(sb[i]);}cout<>ss;int len = ss.size();if(len < 4 || len > 12) return 0;//no answerfor(int i = 0;i < len; ++i)if(ss[i] >= '0' && ss[i]<= '9')vis[ss[i]-'0'] = true;elsest.insert(ss[i]);for(auto it : st) vec.push_back(it);vec_len = vec.size();for(int i = 0; i < len-1; ++i) {for(int j = i + 1;j < len-1; ++j) {for(int k = j + 1 ;k < len - 1; ++k) {sa[0] = ss.substr(0,i + 1);sa[1] = ss.substr(i + 1,j - i);sa[2] = ss.substr(j + 1,k - j);sa[3] = ss.substr(k + 1,len-k-1);for(int l = 0;l < vec_len; ++l) mp[vec[l]] = -1;for(int l = 0;l < 4; ++l) {sb[l] = sa[l];}dfs(0);}}}return 0;}/*input1:11a2b22a037output1:114.252.240.37115.242.250.37input2:20212118136output2:20.212.118.136202.12.118.136202.121.18.136202.121.181.36*/