Codeforces 1352 F. Binary String Reconstruction(构造) 分类构造即可。 AC代码: int main() { int t; sd(t); while (t--) { int a, b, c; sddd(a, b, c); string s; if (a > 0) { rep(i, 0, a) s += "0"; } if (c > 0) { rep(i, 0, c) s += "1"; } if (c)...
While operating for characters i=0 to i=(x-1), u directly set the character in string w as s[i] if (i+x)<n,what if (i+x)>=n, and the string s has a '1' at position i. In that case, you need to print (-1) as the answer. Corrected code Similarly for i =(n-x) t...
#include<iostream>#include<cstdio>#include<cstring>#include<vector>#include<algorithm>usingnamespacestd;intmain(){intt; cin >> t;while(t--) { string s; cin >> s;intx; cin >> x;intlen = s.size();stringres(len,'1');for(inti =0; i < s.size(); ++i) {if(s[i] =='0'&...