description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
T = int(input()) for _ in range(T): s = input() x = int(input()) n = len(s) ans = ["1"] * len(s) for i in range(len(s)): if s[i] == "0": if i - x >= 0: ans[i - x] = "0" if i + x < n: ans[i + x] = "0" f = 1 for i in range(len(s))...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRIN...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
import sys from _collections import deque input = lambda: sys.stdin.readline().rstrip("\r\n") for _ in range(int(input())): a = input() n = len(a) x = int(input()) b = [1] * n ans = 1 for i in range(1, n + 1): if a[i - 1] == "0": if i + x <= n: b[i + x - 1] ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRI...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def answer(A, x): dp = [-1] * len(A) for i in range(len(A)): if i + 1 - x > 0 and i + 1 + x <= len(A): if A[i] == "0": if dp[i - x] == -1: dp[i - x] = "0" elif dp[i - x] != A[i]: return -1 if dp[i + x] ==...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF VAR BIN_OP VAR VAR VAR VAR RETURN NUMBER IF VAR BIN_OP...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for t in range(int(input())): s = input() x = int(input()) n = len(s) w = ["1"] * n for i in range(n): if s[i] == "0": if i >= x: w[i - x] = "0" if i + x < n: w[i + x] = "0" for i in range(n): if s[i] == "1": wi ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): flag = 1 s = input() x = int(input()) n = len(s) l = ["1" for i in range(n)] for i in range(n): if s[i] == "0" and i + x < n: l[i + x] = "0" if s[i] == "0" and i - x >= 0: l[i - x] = "0" for i in range(n): if s[i] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF VAR VAR STRING BIN_O...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) n = len(s) f0 = [1] * n for i in range(n): if s[i] == "0": if i >= x: f0[i - x] = 0 if i + x < n: f0[i + x] = 0 u = 0 for i in range(n): if s[i] == "1": ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def parse(w, x): s = [] for i in range(len(w)): b = 0 if i >= x and w[i - x] == 1: b = 1 if i < len(w) - x and w[i + x] == 1: b = 1 s.append(b) return s def u(r, i, v): if r[i] not in (-1, v): raise ArithmeticError r[i] = v for _ in...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF IF VAR VAR NUMBER VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_C...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for _ in range(t): s = input() x = int(input()) n = len(s) wArr = [(-1) for __ in range(n)] ok = True for i in range(n): if s[i] == "0": if i - x > -1: wArr[i - x] = 0 if i + x < n: wArr[i + x] = 0 for i in rang...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
rr = lambda: input().strip() def constu(w, n, x): sx = list(w) for i in range(n): if i - x >= 0 and w[i - x] == "1" or i + x < n and w[i + x] == "1": sx[i] = "1" else: sx[i] = "0" sx = "".join(sx) return sx def solve(s): x = int(rr()) n = len(s) w ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR STRING BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR FUNC_CALL STRING VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): string = list(input()) x = int(input()) len_str = len(string) w = ["1" for _ in range(len_str)] for ind, s in enumerate(string): if s == "0": if ind - x >= 0: w[ind - x] = "0" if ind + x < len_str: w[ind + ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR VAR...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) ls = len(s) a = [1] * ls for i, k in enumerate(s): if k == "0": if i - x >= 0: a[i - x] = 0 if i + x < ls: a[i + x] = 0 for i, k in enumerate(s): if k == "1": ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP V...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
T = int(input()) for t in range(T): s = input() x = int(input()) n = len(s) ans = [(1) for i in range(n)] for i, a in enumerate(s): if a == "1": continue if i - x >= 0: ans[i - x] = 0 if i + x < n: ans[i + x] = 0 impossible = False ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VA...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
from sys import stdin T = int(stdin.readline().strip()) for caso in range(T): s = stdin.readline().strip() n = int(stdin.readline().strip()) ans = [(1) for i in range(len(s))] can = True res = "" for i in range(len(s)): if s[i] == "0": if i - n >= 0: ans[i - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def func(): n = len(s) w = ["_"] * n for i in range(n): if s[i] == "0": flag = True if i + x < n: w[i + x] = "0" flag = False if i - x > -1: w[i - x] = "0" flag = False if (i - x > -1 or i...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR V...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = list(input().strip()) x = int(input()) n = len(s) f = 0 res = ["1"] * n for i in range(n): if s[i] == "0": if i - x >= 0: res[i - x] = "0" if i + x < n: res[i + x] = "0" for i in range(n): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def dfs(s1, s, x, index, visited): orig = index while index < len(s): visited.add(index) if s[index] == "0": if index - x >= 0: s1[index - x] = "0" if index + x < len(s): s1[index + x] = "0" index += 1 index = orig while ind...
FUNC_DEF ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING VAR NUMBER ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER IF ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) answer = [] for _ in range(t): string = input() x = int(input()) n = len(string) tempo = ["1" for i in range(n)] for i in range(n): if string[i] == "0": if i + x < n: tempo[i + x] = "0" if i - x >= 0: tempo[i - x] = "0"...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for w in range(t): q = str(input("")) x = int(input()) n = len(q) ans = ["1" for i in q] for i in range(0, n): if q[i] == "0": if i - x >= 0: ans[i - x] = "0" if i + x < n: ans[i + x] = "0" ll = False rr = False...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
import sys tc = int(sys.stdin.readline()) for _ in range(tc): s = list(sys.stdin.readline().rstrip()) x = int(sys.stdin.readline()) n = len(s) s = ["-1"] + s w = ["-1"] + ["1"] * n temp = ["-1"] + ["0"] * n match = True for i in range(1, n + 1): if s[i] == "0": if i ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP LIST STRING BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP LIST STRING BIN_OP LIST ST...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
import sys input = sys.stdin.readline def const(S): n = len(S) ANS = ["0"] * n for i in range(n): if i - x >= 0 and S[i - x] == "1": ANS[i] = "1" if i + x < n and S[i + x] == "1": ANS[i] = "1" return "".join(ANS) t = int(input()) for tests in range(t): S ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR STRING ASSIGN VAR VAR STRING IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR STRING ASSIGN VAR VAR STRING RETURN FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def solve(string, x): n = len(string) possible = [{(0): True, (1): True} for i in range(n)] for i in range(n): if string[i] == "0": if i >= x: possible[i - x][1] = False if i + x < n: possible[i + x][1] = False elif i < x and i + x >= n...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR BIN_OP VAR VAR VAR RETURN NUMBER IF VAR VAR ASSI...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() n = len(s) x = int(input()) num = [(1) for i in range(n)] f1 = 0 for i in range(n): di = int(s[i]) if i - x < 0 and i + x >= n: if di == 0: num[i] = 0 elif i - x < 0 and i + x < n: if di == ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR IF VAR NUMBER AS...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for i in range(t): s = list(input()) x = int(input()) temp = [(1) for j in range(len(s))] for j in range(len(s)): if s[j] == "0": if j + x < len(s): temp[j + x] = 0 if j - x >= 0: temp[j - x] = 0 flag = 0 for j in r...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUM...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): s = [int(item) for item in input().rstrip()] x = int(input()) n = len(s) ret1 = [-1] * n for i in range(x, n): if not s[i]: ret1[i - x] = 0 for i in range(n - x): if not s[i]: ret1[...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
from sys import stdin, stdout t = int(stdin.readline()) for _ in range(t): arr = stdin.readline() arr = arr[: len(arr) - 1] w = int(stdin.readline()) n = len(arr) pc = [1] * n counter = 0 for i in range(n): if counter == 1: break if arr[i] == "0": if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR STRING IF BI...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
from sys import stdin, stdout def input(): return stdin.readline().strip() def s_of(w): ret = [] for i in range(len(w)): anchors = [] for j in [i - x, i + x]: if 0 <= j < len(w): anchors += [w[j]] if 1 in anchors: ret += [1] else: ...
FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR IF NUMBER VAR FUNC_CALL VAR VAR VAR LIST VAR VAR IF NUMBER VAR VAR LIST NUMBER VAR LIST NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL V...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): ar = input().rstrip() x = int(input()) n = len(ar) ans = [1] * n for j in range(n): if ar[j] == "0": if j - x >= 0: ans[j - x] = 0 if j + x < n: ans[j + x] = 0 mk = ["0"] * n for i in range(n): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VA...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
import sys def i(): return sys.stdin.readline()[:-1] def getOutList(n, x, binList): outList = [False] * n for b in range(n - x): outList[b] = binList[b + x] for b in range(x, n): outList[b] = outList[b] or binList[b - x] return outList cases = int(i()) for a in range(cases): ...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUN...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def binaryRecon(s, k): r = ["1"] * len(s) for i in range(len(s)): if i - k >= 0 and s[i] == "0": r[i - k] = "0" if i + k < len(s) and s[i] == "0": r[i + k] = "0" flag = checker(r, s, k) if flag: print("".join(r)) return print(-1) def checker(...
FUNC_DEF ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR STRING ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR FUNC_CALL VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR EXPR FUNC_CALL VAR FUN...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
from sys import stdin, stdout input = stdin.readline for _ in range(int(input())): s = input().strip() x = int(input()) w = ["1"] * len(s) for idx, ch in enumerate(s): if ch == "0": if idx - x >= 0: w[idx - x] = "0" if idx + x <= len(s) - 1: ...
ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR BIN_OP FUNC_C...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for i in range(t): s = input() x = int(input()) w = ["1"] * len(s) for j in range(len(s)): if s[j] == "0": if j + x < len(s): w[j + x] = "0" if j - x >= 0: w[j - x] = "0" c = 0 for j in range(len(s)): if s[j...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VA...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) w = [] w = [-1] * len(s) n = len(s) flag = False for i in range(n): if s[i] == "0": if i - x >= 0: w[i - x] = 0 if i + x <= n - 1: w[i + x] = 0 for i in range(n): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for u in range(int(input())): s = input() n = len(s) x = int(input()) d = ["1"] * n f = 0 for i in range(n): if s[i] == "0": if i + x < n: d[i + x] = "0" if i - x >= 0: d[i - x] = "0" for i in range(n): c = 0 if ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR NUMBER A...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def main(): s = input() n = len(s) x = int(input()) t = ["1"] * n for i in range(n): if s[i] == "0": if i - x >= 0: t[i - x] = "0" if i + x < n: t[i + x] = "0" for i in range(n): if s[i] == "1": one = False ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING FOR VAR FUNC_CALL VAR VAR I...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
tests = int(input()) for t in range(tests): string = list(input()) x = int(input()) string_len = len(string) res = [(-1) for _ in range(string_len)] check = True for idx, item in enumerate(string): if item == "0": if idx >= x: if res[idx - x] == -1 or res[idx ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR VAR IF VAR BIN_OP VAR VAR NUMBER VAR BI...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = [x for x in input()] h = s.copy() n = int(input()) dicti = {} come = 0 for i in range(len(s)): if s[i] == "0": if i < n and i > len(s) - n - 1: continue elif i < n: h[i + n] = "0" if...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR B...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for i in range(t): s = input() n = int(input()) l = len(s) arr = ["1"] * l flag = 1 for i in range(l): if s[i] == "0": if i - n >= 0: arr[i - n] = "0" if i + n < l: arr[i + n] = "0" for i in range(l): if...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_O...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def process(): li = list(input()) x = int(input()) n = len(li) ans = ["1" for i in range(n)] for i in range(0, n): if li[i] == "0": if i - x >= 0: ans[i - x] = "0" if i + x < n: ans[i + x] = "0" for i in range(0, n): chr = "...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
from sys import * ws = lambda: map(int, stdin.readline().strip().split()) li = lambda: list(map(int, stdin.readline().strip().split())) mod = 1000000007 def ncr(n, r, p): num = den = 1 for i in range(r): num = num * (n - i) % p den = den * (i + 1) % p return num * pow(den, p - 2, p) % p ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for j in range(t): s = input() x = int(input()) n = len(s) w = ["1"] * n for i in range(n): if s[i] == "0": if i - x >= 0: w[i - x] = "0" if i + x < n: w[i + x] = "0" p = [-1] * n for i in range(n): if i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR VAR ASSI...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for i in range(t): s = input() x = int(input()) n = len(s) l = ["2"] * n check = True for i in range(n): if s[i] == "1": if i - x < 0 and i + x < n: if l[i + x] == "0": check = False l[i + x] = "1" ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR IF VAR BIN_OP VAR VAR ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
T = int(input()) output = ["0"] * T for t in range(T): s = input() n = len(s) x = int(input()) w = ["1"] * n s_new = ["0"] * n for i, si in enumerate(s): if si == "0": if i >= x: w[i - x] = "0" if i + x < n: w[i + x] = "0" for i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR VAR ASSIG...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) while t: s = input() x = int(input()) n = len(s) l1 = ["2" for i in range(0, n)] check = 0 for i in range(0, n): if i + x < n and i - x > -1: if s[i] == "0": if l1[i - x] == "1" or l1[i + x] == "1": check = 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR BIN_OP VAR VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def fun(): s = input() x = int(input()) ls = [(1) for i in range(len(s))] for i in range(len(s)): if s[i] == "0": if i - x >= 0: ls[i - x] = 0 if i + x < len(s): ls[i + x] = 0 f = True for i in range(len(s)): if s[i] == "1":...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN V...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) ans = ["1"] * len(s) for i in range(len(s)): if s[i] == "0": if i < len(s) - x: ans[i + x] = "0" if i >= x: ans[i - x] = "0" correct = True for j in range(len(s)): r...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF VAR VAR ASSIGN VAR BIN_OP VA...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): S = input() x = int(input()) s = "" n = len(S) for i in range(n): if x <= i and S[i - x] == "0" or i < n - x and S[i + x] == "0": s += "0" else: s += "1" for i in range(n): if S[i] == "1": if x <= i and s[i...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR VAR STRING VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR STRING VAR STRING VAR STRING FOR VAR FUNC_CALL VAR VAR IF ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
gans = [] for _ in range(int(input())): s = list(map(int, list(input()))) n = len(s) x = int(input()) w = [1] * n for i in range(n): if s[i] == 0: if i - x >= 0: w[i - x] = 0 if i + x < n: w[i + x] = 0 ok = False for i in range(...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR B...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
import sys t = int(input()) def solve(): w = input() n = len(w) x = int(input()) print("[LOG] solve(w=", w, ", x=", x, ")", file=sys.stderr) def is_zero(pos): if pos <= 0 or pos > n: return True before = pos + x <= n and w[pos + x - 1] == "0" after = pos - x >...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING VAR STRING VAR STRING VAR FUNC_DEF IF VAR NUMBER VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER STRING ASSIG...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) n = len(s) w = [""] * n f = True for i in range(n): if s[i] == "0": if i >= x: w[i - x] = "0" if i < n - x: w[i + x] = "0" for i in range(n): if s[i] == "1": ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for p in range(int(input())): st = input() x = int(input()) n = len(st) w = [1] * n for i in range(n): if st[i] == "0": if i - x >= 0: w[i - x] = 0 if i + x < n: w[i + x] = 0 ans = "" for i in range(n): if i - x >= 0 and...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP V...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) s = " " + s prev = [0] * (len(s) + 1) prev[0] = -1 prev[-1] = -1 for i in range(1, len(s)): if s[i] == "0": prev[max(i - x, 0)] = -1 prev[min(i + x, len(s))] = -1 ok = True for i in range(1, le...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
T = int(input()) for _ in range(T): S = input() N = int(input()) L = len(S) arr = [0] * L iszero = [False] * L for i in range(L): if S[i] == "0": if i - N >= 0: iszero[i - N] = True if i + N < L: iszero[i + N] = True used = Fals...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
import sys input = sys.stdin.readline for _ in range(int(input())): s = list(input().strip()) n = len(s) x = int(input()) r = [-1] * n for i in range(n): if s[i] == "0": if i - x >= 0: r[i - x] = "0" if i + x < n: r[i + x] = "0" fo...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ST...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) while t > 0: s = input() x = int(input()) n = len(s) def helper(n, s, x): w = "1" * n w = list(w) for i in range(n): if s[i] == "0": if i + x < n: w[i + x] = "0" if i - x >= 0: w...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF BI...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
import sys def input(): return sys.stdin.readline().rstrip("\r\n") def maps(): return [int(i) for i in input().split()] def check(s, w, n, x): for i in range(n): ok = False if s[i] == "1": if i >= x and w[i - x] == "1": ok = True elif i + x < n a...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR STRING IF VAR VAR VAR BIN_OP VAR VAR STRING ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR STRING ASSIGN VAR NUMBER IF BIN_OP VA...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for i in range(t): s = input() n = len(s) x = int(input()) w = ["1" for j in range(n)] for j in range(n - x): if s[j + x] == "0": w[j] = "0" f = True for j in range(x, n): if s[j - x] == "0": w[j] = "0" for j in range(n): i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR BIN_OP VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CAL...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def solve(s, x, n, w): for i in range(n): if s[i] == "0": if i >= x: w[i - x] = "0" if i + x < n: w[i + x] = "0" for i in range(n): if s[i] == "1": works = False if i >= x: if w[i - x] == "1": ...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER IF VAR VAR IF VAR BIN_OP VAR VAR STRING ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR IF VAR BIN_OP VAR VAR STRI...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = list(map(int, list(input()))) n = len(s) x = int(input()) res = [1] * n for i in range(n): if s[i] == 0: if i + x < n: res[i + x] = 0 if i - x >= 0: res[i - x] = 0 bad = False for i in range(n):...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBE...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) while t: s = input() n = len(s) x = int(input()) a = ["_" for i in range(n)] for i in range(n): if s[i] == "0": if i - x >= 0: a[i - x] = "0" if i + x < n: a[i + x] = "0" flag = True for i in range(n): i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
import sys def controller(s, x): n = len(s) s = tuple(i == "1" for i in s) w = [None] * n constraints = [] for i, si in enumerate(s): a = i - x b = i + x has_a = 0 <= a has_b = b < n if has_a: if has_b: if si: ...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING VAR VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER VAR ASSIGN VAR VAR VAR IF VAR IF VAR IF VAR EXPR FUNC_CALL VAR VAR IF VAR VAR NONE ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for _ in range(t): flag = True w = str(input()) x = int(input()) s = [-1] * len(w) for i, ch in enumerate(w): if ch == "0": if i - x >= 0: s[i - x] = 0 if i + x < len(w): s[i + x] = 0 for i, ch in enumerate(w): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() n = len(s) x = int(input()) w = ["1"] * n for i in range(n): if s[i] == "0": if i + x < n: w[i + x] = "0" if i - x > -1: w[i - x] = "0" check = ["0"] * n for i in range(n): if i ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP V...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
T = int(input()) while T > 0: str = [] w = input() x = int(input()) n = len(w) - 1 flag = False for i in range(0, 2 * n + 1): str.append(-1) for i in range(0, x): for j in range(i, n + 1, x): if j == i: if j + x > n and w[j] == "1": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for _ in range(t): s = list(input()) x = int(input()) n = len(s) res = ["1"] * n for i in range(n): if s[i] == "0": if i + x < n: res[i + x] = "0" if i - x >= 0: res[i - x] = "0" flag = True for i in range(n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR V...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for tt in range(0, t): sti = input() s = list(sti) n = len(s) x = int(input()) ans = ["0"] * n for i in range(0, n): j = i - x fut = i + x if j >= 0 and fut < n: if s[j] == "1" and s[fut] == "1": ans[i] = "1" elif j >= ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for case in range(t): s = list(map(int, list(input()))) x = int(input()) n = len(s) w = [1] * n for i in range(n): if s[i] == 0: if i + 1 > x: w[i - x] = 0 if i + 1 + x <= n: w[i + x] = 0 newS = [0] * n for i in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BI...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) w1 = "1" * len(s) w = list(w1) f = 0 for i in range(len(s)): if s[i] == "0": if i - x >= 0 and i + x <= len(s) - 1: w[i - x] = "0" w[i + x] = "0" elif i - x < 0 and i + x <=...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR BIN_OP FUNC_CALL V...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = list(map(int, input())) x = int(input()) n = len(s) dp = [(-1) for i in range(n)] vis = [(0) for i in range(n)] f = 0 for i in range(n): if s[i] == 0: if i - x >= 0: dp[i - x] = 0 if i + x < n: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for _ in range(t): s = list(str(input())) x = int(input()) w = ["1" for _ in range(len(s))] for i in range(len(s)): if s[i] == "0": if i - x >= 0: w[i - x] = "0" if i + x < len(s): w[i + x] = "0" flag = False for i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input("")) arr = [] x = [] for i in range(t): arr.append(input("")) x.append(int(input(""))) for i in range(t): s = list(arr[i]) y = x[i] n = len(s) dp = ["1"] * n flag = 0 for j in range(n): if s[j] == "0": if j - y >= 0: dp[j - y] = "0" ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) n = len(s) ans = ["1"] * n ok = True for i in range(n): if s[i] == "0": if i - x >= 0: ans[i - x] = "0" if i + x < n: ans[i + x] = "0" for i in range(n): one = F...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR VAR A...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def run(s, x): n = len(s) ans = ["2" for i in range(n)] for i in range(n): if s[i] == "0": if i - x >= 0: ans[i - x] = "0" if i + x < n: ans[i + x] = "0" for i in range(n): if s[i] == "1": flag = False if i -...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBE...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) n = len(s) w = ["1" for _ in range(n)] for i in range(n): if s[i] == "0": if i >= x: w[i - x] = "0" if i + x < n: w[i + x] = "0" check = True for i in range(n): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR S...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
from sys import * input = stdin.readline for _ in range(int(input())): s = input() x = int(input()) n = len(s) - 1 w = ["-1"] * n for i in range(n): if s[i] == "0": if 0 <= i + x < n: w[i + x] = "0" if 0 <= i - x < n: w[i - x] = "0" ...
ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF NUMBER BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF NUMBE...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def solve(): T = int(input()) def f(s, x): res = ["0" for i in range(len(s))] for i in range(len(res)): if i - x >= 0 and s[i - x] == "1" or i + x < len(s) and s[i + x] == "1": res[i] = "1" else: res[i] = "0" return "".join(res) ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR STRING VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR STRING BIN_OP VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING RETURN FUNC_CAL...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
dx = [0, 0, -1, 1] dy = [1, -1, 0, 0] def solve(s, x): ans = [1] * len(s) for i in range(len(s)): if s[i] == "0": if i - x >= 0: ans[i - x] = 0 if i + x < len(s): ans[i + x] = 0 work = True for i in range(len(s)): if s[i] == "1": ...
ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR V...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
from sys import stdin def inp(): return stdin.buffer.readline().rstrip().decode("utf8") def itg(): return int(stdin.buffer.readline()) def mpint(): return map(int, stdin.buffer.readline().split()) def solve(): s = inp() x = itg() n = len(s) w = ["1"] * n for i in range(n): ...
FUNC_DEF RETURN FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR ST...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for g in range(0, t): s = list(input()) a = [] for i in range(0, len(s)): a.append(-1) x = int(input()) ans = 1 for i in range(0, len(s)): if s[i] == "0": if i + x < len(s): a[i + x] = "0" if i - x >= 0: a[i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRIN...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for i in range(int(input())): s = list(str(input())) x = int(input()) ss = "1" * len(s) s = list(s) ss = list(ss) for i in range(len(s)): if s[i] == "0": if i - x >= 0 and i - x < len(s): ss[i - x] = "0" if i + x <= len(s) - 1 and i + x >= 0: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR N...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
from sys import stdin nii = lambda: map(int, stdin.readline().split()) lnii = lambda: list(map(int, stdin.readline().split())) t = int(input()) for tt in range(t): s = list(map(lambda x: int(x), list(input()))) x = int(input()) n = len(s) ans = [(1) for i in range(n)] for i in range(n): if ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) while t: s = input() x = int(input()) ans = ["1" for i in range(len(s))] for i in range(len(s)): if s[i] == "0": if i >= x: ans[i - x] = "0" if i + x < len(s): ans[i + x] = "0" ans2 = ["1" for i in range(len(ans))] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
import sys sys.setrecursionlimit(10000) t = int(input()) for _ in range(t): s = input() x = int(input()) n = len(s) sed = False w = ["0"] * n fixed = [0] * n for i in range(x): if i + x < n: w[i + x] = s[i] fixed[i + x] = 1 elif s[i] == "1": ...
IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = str(input()) x = int(input()) n = len(s) w = [1] * n for i in range(n): if i - x >= 0 and s[i] == "0": w[i - x] = 0 if i + x < n and s[i] == "0": w[i + x] = 0 f = 0 for i in range(n): if s[i] == "1": ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR STRING ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR ...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) l = [1] * len(s) for i in range(len(s)): if s[i] == "0": if i + x < len(s): l[i + x] = 0 if i - x >= 0: l[i - x] = 0 ans = [0] * len(s) for i in range(len(s)): if l[...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for i in range(t): s = input() x = int(input()) l = len(s) val = ["1" for j in range(l)] for j in range(l): if s[j] == "0": if j - x >= 0: val[j - x] = "0" if j + x < l: val[j + x] = "0" f = 0 for j in range(l):...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR VA...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = str(input()) x = int(input()) n = len(s) temp = True ans = [(1) for l in range(n)] for i in range(n): if s[i] == "0": if i >= x: ans[i - x] = 0 if i + x < n: ans[i + x] = 0 for i in range(n): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for _ in range(t): s = list(input()) n = len(s) x = int(input()) ans = [1] * n flag = 0 for i in range(n): if s[i] == "0": if i + x < n: ans[x + i] = 0 if i - x >= 0: ans[i - x] = 0 res = [-1] * n for i in r...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMB...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): str = input() x = int(input()) n = len(str) ans = ["1"] * n for i in range(n): if str[i] == "0": if i - x >= 0: ans[i - x] = "0" if i + x < n: ans[i + x] = "0" cnd = True for i in range(n): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP V...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
n = int(input()) for i in range(1, n + 1): s = input() nn = len(s) x = int(input()) ans = "1" * nn for i in range(nn): if s[i] == "0": if i - x >= 0: index = i - x ans = ans[:index] + "0" + ans[index + 1 :] if i + x < nn: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for ii in range(t): s = input() x = int(input()) ans = [-1] * len(s) can = True for i in range(len(s)): back = i - x front = i + x sor = False if s[i] == "1": if back >= 0: if ans[back] == -1 or ans[back] == 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR VAR STRI...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for _ in range(t): s = input() x = int(input()) w = [-1] * len(s) for i in range(len(s)): ch = s[i] if ch == "0": if i - x >= 0: w[i - x] = 0 if i + x < len(s): w[i + x] = 0 for i in range(len(s)): ch = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VA...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
t = int(input()) for i in range(t): s = str(input()) x = int(input()) n = len(s) lis = [-1] * n z = 0 for j in range(n): if s[j] == "0": if j + x <= n - 1: lis[j + x] = 0 if j - x >= 0: lis[j - x] = 0 for j in range(n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_O...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
test = int(input()) for _ in range(test): w = list(input()) x = int(input()) n = len(w) s = [-1] * n for i in range(n): w[i] = int(w[i]) if w[i] == 0: if i - x >= 0: s[i - x] = 0 if i + x < n: s[i + x] = 0 resflag = True ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN V...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def solve(): s = input() x = int(input()) w = ["."] * len(s) for i in range(len(s)): if s[i] == "0": if i - x >= 0: w[i - x] = "0" if i + x < len(s): w[i + x] = "0" for i in range(len(s)): if s[i] == "1": if i - x >=...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING IF BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR STRING FOR VAR FUNC_C...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) n = len(s) dp = [-1] * n flag = 0 for i in range(n): if s[i] == "0": if i - x >= 0: dp[i - x] = 0 if i + x < n: dp[i + x] = 0 def check(arr): for i in range(n):...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR A...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) ans = ["1"] * len(s) fc = ["x"] * len(s) flag = 0 n = len(s) for i in range(n): if s[i] == "0": if i - x >= 0: ans[i - x] = "0" if i + x < n: ans[i + x] = "0" for i ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR N...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for i in range(int(input())): s = input() x = int(input()) n = len(s) w = ["#"] * n flag = True for j in range(n): if j + 1 - x <= 0: if j + 1 + x > n: if s[j] == "1": flag = False break elif s[j] == "0": ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR VAR IF VAR VAR STRING ASSIGN...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
for _ in range(int(input())): s = input() x = int(input()) n = len(s) dp = [(1) for i in range(n)] for i in range(n): if s[i] == "0": if i - x >= 0: dp[i - x] = 0 if i + x < n: dp[i + x] = 0 w = "" for i in range(n): b =...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BI...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
a = int(input()) for i in range(a): s = input() ans = [] flag = 1 for i in range(len(s)): ans.append(s[i]) x = int(input()) te = [1] * len(s) for i in range(len(s)): if s[i] == "0": if i - x >= 0: te[i - x] = 0 if i + x < len(s): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF...
Consider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th character of $s$ is chosen as follows: if the character $w_{i-x}$ exists and is equal to 1, then $...
def solve(): s = input() n = len(s) x = int(input()) ans = ["0" for i in range(n)] for i in range(n): if s[i] == "1": if i >= 2 * x and s[i - 2 * x] == "1": ans[i - x] = "1" elif i >= x and i < 2 * x: ans[i - x] = "1" elif i...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP NUMBER VAR VAR BIN_OP VAR BIN_OP NUMBER VAR STRING ASSIGN VAR BIN_OP VAR VAR STRING IF VAR VAR VAR BIN_OP NUMBER VAR ASS...