description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
first = input() second = input() adad = list() for i in range(len(first)): num = 0 if first[i] == "0": num += 1 if second[i] == "0": num += 1 adad.append(num) cnt = 0 last_fill = -1 for i in range(1, len(adad)): if adad[i] + adad[i - 1] == 3: cnt += 1 adad[i] = adad[i - 1] = 0 elif adad[i] + adad[i - 1] == 4: cnt += 1 adad[i] = 1 adad[i - 1] = 0 print(cnt)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
board = [] board.append(input()) board.append(input()) n = len(board[0]) dp = [[(0) for _ in range(n)] for _ in range(4)] inf = float("-inf") if board[0][0] == "X": dp[0][0] = inf dp[2][0] = inf if board[1][0] == "X": dp[0][0] = inf dp[1][0] = inf for i in range(1, n): prev_best = max(dp[j][i - 1] for j in range(4)) for j in range(4): dp[j][i] = prev_best if board[0][i] != "X" or board[1][i] != "X": dp[3][i] = max(dp[3][i], dp[0][i - 1] + 1) if board[0][i] != "X" and board[1][i] != "X": dp[1][i] = max(dp[1][i], dp[0][i - 1] + 1) dp[2][i] = max(dp[2][i], dp[0][i - 1] + 1) dp[3][i] = max(dp[3][i], dp[1][i - 1] + 1, dp[2][i - 1] + 1) if board[0][i] == "X": dp[0][i] = inf dp[2][i] = inf if board[1][i] == "X": dp[0][i] = inf dp[1][i] = inf print(max(max(dp[i][-1] for i in range(4)), 0))
ASSIGN VAR LIST EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER NUMBER STRING ASSIGN VAR NUMBER NUMBER VAR ASSIGN VAR NUMBER NUMBER VAR IF VAR NUMBER NUMBER STRING ASSIGN VAR NUMBER NUMBER VAR ASSIGN VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR VAR IF VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
def change(i, val): vis[0][i] = 1 vis[1][i] = 1 if val == 0: vis[0][i - 1] = 1 elif val == 1: vis[1][i - 1] = 1 elif val == 2: vis[0][i + 1] = 1 else: vis[1][i + 1] = 1 def solve(x, y, val): if val < 0 or val >= n: return False if vis[x][val] == 0: return True return False mat = list() n = 0 for i in range(2): lis = input() n = len(lis) mat.append(lis) vis = [([0] * n) for i in range(2)] for i in range(2): for j in range(n): if mat[i][j] == "X": vis[i][j] = 1 ans = 0 for i in range(n): if vis[0][i] != 1 and vis[1][i] != 1: found = False if solve(0, i, i - 1): found = True val = 0 elif solve(1, i, i - 1) and not found: found = True val = 1 elif solve(0, i, i + 1) and not found: found = True val = 2 elif solve(1, i, i + 1) and not found: found = True val = 3 if found: ans += 1 change(i, val) print(ans)
FUNC_DEF ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER FUNC_DEF IF VAR NUMBER VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR STRING ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
ch = input() cha = input() i = 0 ans = 0 while i <= len(ch) - 2: cnt = 0 if ch[i] == "0": cnt += 1 if cha[i] == "0": cnt += 1 if ch[i + 1] == "0": cnt += 1 if cha[i + 1] == "0": cnt += 1 if cnt == 4: if i + 2 <= len(ch) - 1: if ch[i + 2] == "0" and cha[i + 2] == "0": ans += 2 i += 3 else: ans += 1 i += 2 else: ans += 1 i += 2 elif cnt == 3: ans += 1 i += 2 else: i += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
str1 = input() str2 = input() count = 0 for i in range(len(str1) - 1): if str1[i] == "0" and str1[i + 1] == "0" and str2[i] == "0": count = count + 1 str1 = str1[:i] + "X" + str1[i + 1 :] str1 = str1[: i + 1] + "X" + str1[i + 2 :] str2 = str2[:i] + "X" + str2[i + 1 :] elif str1[i] == "0" and str1[i + 1] == "0" and str2[i + 1] == "0": count = count + 1 str1 = str1[:i] + "X" + str1[i + 1 :] str1 = str1[: i + 1] + "X" + str1[i + 2 :] str2 = str2[: i + 1] + "X" + str2[i + 2 :] elif str1[i + 1] == "0" and str2[i] == "0" and str2[i + 1] == "0": count = count + 1 str1 = str1[: i + 1] + "X" + str1[i + 2 :] str2 = str2[:i] + "X" + str2[i + 1 :] str2 = str2[: i + 1] + "X" + str2[i + 2 :] elif str1[i] == "0" and str2[i] == "0" and str2[i + 1] == "0": count = count + 1 str1 = str1[:i] + "X" + str1[i + 1 :] str2 = str2[:i] + "X" + str2[i + 1 :] str2 = str2[: i + 1] + "X" + str2[i + 2 :] print(count)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = input() s1 = input() l = [[], []] for i in range(len(s)): l[0].append(s[i]) l[1].append(s1[i]) k = 0 for i in range(len(s) - 1): if l[0][i] == l[1][i] == l[0][i + 1] == "0": k += 1 l[0][i + 1] = "X" continue if l[0][i] == l[1][i] == l[1][i + 1] == "0": k += 1 l[1][i + 1] = "X" continue if ( l[0][i] == l[1][i + 1] == l[0][i + 1] == "0" or l[1][i] == l[1][i + 1] == l[0][i + 1] == "0" ): k += 1 l[1][i + 1] = "X" l[0][i + 1] = "X" print(k)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST LIST LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
def main(): a, b = [i for i in input()], [i for i in input()] l = len(a) c = 0 for i in range(l - 1): if a[i] == "0": if b[i] == "0": if a[i + 1] == "0": c += 1 a[i], b[i], a[i + 1] = 1, 1, 1 elif b[i + 1] == "0": c += 1 a[i], b[i], b[i + 1] = 1, 1, 1 elif a[i + 1] == "0" and b[i + 1] == "0": c += 1 a[i], a[i + 1], b[i + 1] = 1, 1, 1 elif b[i] == "0" and b[i + 1] == "0" and a[i + 1] == "0": c += 1 b[i], a[i + 1], b[i + 1] = 1, 1, 1 print(c) return 0 main()
FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR RETURN NUMBER EXPR FUNC_CALL VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = input() b = input() NONE = 0 BOT = 1 TOP = 2 BOTH = 3 inp = [(2 * (i == "0") + (j == "0")) for i, j in zip(a, b)] assert all(0 <= i < 4 for i in inp) n = len(inp) out = 0 for i in range(n): if inp[i] == NONE: continue elif inp[i] == BOTH: if i != 0 and inp[i - 1] != NONE: inp[i] = NONE out += 1 elif i != n - 1 and inp[i + 1] != NONE: inp[i] = NONE if inp[i + 1] != BOTH: inp[i + 1] = NONE else: inp[i + 1] = BOT out += 1 else: continue print(out)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR STRING VAR STRING VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF VAR VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
FREE = "0" def value(ch): return 0 if ch == FREE else 1 def calc(s): n = len(s) sm = 0 m = [(0) for i in range(2)] sp = list() for i, chch in enumerate(s): m[0] += chch[0] m[1] += chch[1] sss = chch[0] + chch[1] sm += sss sp.append(sss) if sss == 2: return calc(s[:i]) + calc(s[i + 1 :]) if n < 2: return 0 if n == 2: return 1 if sm < 2 else 0 if n == 3: if sm == 0: return 2 if sm in [1, 2]: return 1 return 0 cnt = 0 last_busy_two, last_busy_one = False, False for i, chch in enumerate(s): if sp[i] == 0: if last_busy_two or last_busy_one: last_busy_two, last_busy_one = False, not last_busy_one cnt += 1 else: last_busy_two, last_busy_one = True, False elif last_busy_two: last_busy_two, last_busy_one = False, False cnt += 1 else: last_busy_one = True pass return cnt def get_ints(): return [int(n) for n in input().split()] def get_floats(): return [float(n) for n in input().split()] st1, st2 = input(), input() assert len(st1) == len(st2) n = len(st1) s = list() for i in range(n): s.append((value(st1[i]), value(st2[i]))) res = calc(s) print(res)
ASSIGN VAR STRING FUNC_DEF RETURN VAR VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN VAR NUMBER NUMBER NUMBER IF VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR LIST NUMBER NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR ASSIGN VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
coor___top = input() coor___bot = input() coor_len = len(coor___bot) curr_coor___s_nr = {(coor___top[0] + coor___bot[0]): 0} next_coor___s_nr = {"XX": -1, "X0": -1, "0X": -1, "00": -1} for coor in range(1, coor_len): next_sym = coor___top[coor] + coor___bot[coor] for curr_sym in curr_coor___s_nr: curr_s_nr = curr_coor___s_nr[curr_sym] next_coor___s_nr[next_sym] = max(next_coor___s_nr[next_sym], curr_s_nr) if next_sym in ["X0", "0X"] and curr_sym == "00": next_coor___s_nr["XX"] = max(next_coor___s_nr["XX"], curr_s_nr + 1) if next_sym == "00" and curr_sym in ["X0", "0X"]: next_coor___s_nr["XX"] = max(next_coor___s_nr["XX"], curr_s_nr + 1) if curr_sym == "00" and next_sym == "00": next_coor___s_nr["X0"] = max(next_coor___s_nr["X0"], curr_s_nr + 1) next_coor___s_nr["0X"] = max(next_coor___s_nr["0X"], curr_s_nr + 1) curr_coor___s_nr = next_coor___s_nr next_coor___s_nr = {"XX": -1, "X0": -1, "0X": -1, "00": -1} print(max(curr_coor___s_nr.values()))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR DICT STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR FOR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR LIST STRING STRING VAR STRING ASSIGN VAR STRING FUNC_CALL VAR VAR STRING BIN_OP VAR NUMBER IF VAR STRING VAR LIST STRING STRING ASSIGN VAR STRING FUNC_CALL VAR VAR STRING BIN_OP VAR NUMBER IF VAR STRING VAR STRING ASSIGN VAR STRING FUNC_CALL VAR VAR STRING BIN_OP VAR NUMBER ASSIGN VAR STRING FUNC_CALL VAR VAR STRING BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR DICT STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s1 = input() s2 = input() desk = [list(s1), list(s2)] ln = len(s1) ans = 0 def need(i): return [desk[0][i : i + 2], desk[1][i : i + 2]] for i in range(ln - 1): if need(i) == [["0", "0"], ["0", "0"]] or need(i) == [["0", "0"], ["0", "X"]]: desk[0][i] = "X" desk[0][i + 1] = "X" desk[1][i] = "X" elif need(i) == [["0", "0"], ["X", "0"]]: desk[0][i] = "X" desk[0][i + 1] = "X" desk[1][i + 1] = "X" elif need(i) == [["0", "X"], ["0", "0"]]: desk[0][i] = "X" desk[1][i] = "X" desk[1][i + 1] = "X" elif need(i) == [["X", "0"], ["0", "0"]]: desk[0][i + 1] = "X" desk[1][i] = "X" desk[1][i + 1] = "X" else: continue ans += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF RETURN LIST VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR LIST LIST STRING STRING LIST STRING STRING FUNC_CALL VAR VAR LIST LIST STRING STRING LIST STRING STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF FUNC_CALL VAR VAR LIST LIST STRING STRING LIST STRING STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF FUNC_CALL VAR VAR LIST LIST STRING STRING LIST STRING STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF FUNC_CALL VAR VAR LIST LIST STRING STRING LIST STRING STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
3 def o(c): return c == "0" def solve(A, B, N): A += "XXX" B += "XXX" i = 0 c = 0 while i < N: if ( o(A[i]) and o(A[i + 1]) and o(A[i + 2]) and o(B[i]) and o(B[i + 1]) and o(B[i + 2]) ): c += 2 i += 3 continue x = len([x for x in [o(A[i]), o(A[i + 1]), o(B[i]), o(B[i + 1])] if x]) if x >= 3: c += 1 i += 2 continue i += 1 return c def main(): A = input() B = input() N = len(A) assert len(B) == N print(solve(A, B, N)) def __starting_point(): main() __starting_point()
EXPR NUMBER FUNC_DEF RETURN VAR STRING FUNC_DEF VAR STRING VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
def solution(): l = [] s = input() s1 = input() l.append(s) l.append(s1) ans = 0 cur = 0 empty = 0 for i in range(len(s)): cur = 0 if l[1][i] == "0": cur += 1 if l[0][i] == "0": cur += 1 empty += cur if empty >= 3: empty -= 3 ans += 1 else: empty = cur print(ans) solution()
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
field = [list(input()) for _ in range(2)] ans = 0 for i in range(len(field[0]) - 1): if field[0][i] == "0" and field[1][i] == "0": if field[0][i + 1] == "0": ans += 1 field[0][i] = "." field[1][i] = "." field[0][i + 1] = "." elif field[1][i + 1] == "0": ans += 1 field[0][i] = "." field[1][i] = "." field[1][i + 1] = "." elif field[0][i] == "0": if field[0][i + 1] == "0" and field[1][i + 1] == "0": ans += 1 field[0][i] = "." field[0][i + 1] = "." field[1][i + 1] = "." elif field[1][i] == "0": if field[0][i + 1] == "0" and field[1][i + 1] == "0": ans += 1 field[1][i] = "." field[0][i + 1] = "." field[1][i + 1] = "." print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = input() b = input() ct = 0 i = 0 while i < len(a): if ( i + 2 < len(a) and a[i] == "0" and a[i + 1] == "0" and a[i + 2] == "0" and b[i] == "0" and b[i + 1] == "0" and b[i + 2] == "0" ): ct += 2 i += 2 elif a[i : i + 2].count("0") + b[i : i + 2].count("0") >= 3: ct += 1 i += 1 i += 1 print(ct)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
first = input() second = input() n = len(first) up = 0 dw = 0 poss = 0 for i in range(n): if first[i] == "0" and second[i] == "0": up += 1 dw += 1 if up > dw: up -= 2 dw -= 1 poss += 1 elif dw > up: dw -= 2 up -= 1 poss += 1 elif first[i] == "0" and second[i] == "X": both = min(up, dw) if both >= 3: poss += both // 3 * 2 up %= 3 dw %= 3 up += 1 if dw > 1 and up >= 1: poss += 1 up = 1 dw = 0 elif dw >= 1 and up > 1: poss += 1 up = min(up - 2, 1) dw = 0 else: up = 1 dw = 0 elif first[i] == "X" and second[i] == "0": both = min(up, dw) if both >= 3: poss += both // 3 * 2 up %= 3 dw %= 3 dw += 1 if up > 1 and dw >= 1: poss += 1 dw = 1 up = 0 elif up >= 1 and dw > 1: poss += 1 dw = min(dw - 2, 1) up = 0 else: dw = 1 up = 0 else: both = min(up, dw) if both >= 3: poss += both // 3 * 2 up %= 3 dw %= 3 if max(up, dw) > 1 and min(up, dw) >= 1: poss += 1 up = 0 dw = 0 both = min(up, dw) if both >= 3: poss += both // 3 * 2 up %= 3 dw %= 3 if max(up, dw) > 1 and min(up, dw) >= 1: poss += 1 print(poss)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
def f(a, b, c, d): x, y, z, w = 0, 0, 0, 0 if a == "0": x += 1 if b == "0": y += 1 if c == "0": z += 1 if d == "0": w += 1 return x + y + z + w a = list(input()) b = list(input()) c = 0 for i in range(len(a) - 1): if f(a[i], a[i + 1], b[i], b[i + 1]) == 3: a[i], a[i + 1], b[i], b[i + 1] = "X", "X", "X", "X" c += 1 elif f(a[i], a[i + 1], b[i], b[i + 1]) == 4: a[i], a[i + 1], b[i] = "X", "X", "X" c += 1 print(c)
FUNC_DEF ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING STRING STRING STRING VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR STRING STRING STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
l1 = list(input()) l2 = list(input()) count = 0 for i in range(1, len(l1)): if l1[i - 1] == "0" and l2[i - 1] == "0" and l1[i] == "0": count += 1 l1[i - 1] = l1[i] = l2[i - 1] = "X" if l1[i] == "0" and l1[i - 1] == "0" and l2[i] == "0": count += 1 l1[i] = l1[i - 1] = l2[i] = "X" if l2[i] == "0" and l2[i - 1] == "0" and l1[i] == "0": count += 1 l2[i] = l1[i] = l2[i - 1] = "X" if l2[i - 1] == "0" and l1[i - 1] == "0" and l2[i] == "0": count += 1 l2[i] = l2[i - 1] = l1[i - 1] = "X" print(count)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
F = [i for i in input()] S = [i for i in input()] N = len(F) if N == 1: print(0) exit() Ans = 0 for i in range(N - 1): if S[i] == "0" and F[i] == "0": if S[i + 1] == "0": Ans += 1 S[i] = "X" S[i + 1] = "X" F[i] = "X" elif F[i + 1] == "0": Ans += 1 S[i] = "X" S[i] = "X" F[i + 1] = "X" elif S[i] == "0": if S[i + 1] == "0" and F[i + 1] == "0": Ans += 1 S[i] = "X" S[i + 1] = "X" F[i + 1] = "X" elif F[i] == "0": if S[i + 1] == "0" and F[i + 1] == "0": Ans += 1 S[i] = "X" S[i + 1] = "X" F[i + 1] = "X" i = N - 1 if S[i] == "0" and F[i] == "0": if S[i - 1] == "0": Ans += 1 elif F[i - 1] == "0": Ans += 1 elif S[i] == "0": if S[i - 1] == "0" and F[i - 1] == "0": Ans += 1 elif F[i] == "0": if S[i - 1] == "0" and F[i - 1] == "0": Ans += 1 print(Ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = ["", ""] s[0] = input() s[1] = input() pcs = 0 emp = 0 half = False n = len(s[1]) for i in range(n): if s[0][i] == "0" and s[1][i] == "0": emp += 1 if emp == 3: emp = 0 pcs += 2 if emp == 1 and half: pcs += 1 emp = 0 half = False elif s[0][i] == "X" and s[1][i] == "X": if emp == 2: pcs += 1 emp = 0 half = False else: half = True if emp == 2: pcs += 1 elif emp == 1: half = False pcs += 1 emp = 0 if emp == 3: pcs += 2 elif emp == 2: pcs += 1 elif emp == 1 and half: pcs += 1 print(pcs)
ASSIGN VAR LIST STRING STRING ASSIGN VAR NUMBER FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = list(input()) b = list(input()) r = 0 for i in range(len(a) - 1): if a[i] == "0" and b[i] == "0": if a[i + 1] == "0": a[i + 1] = "X" r += 1 elif b[i + 1] == "0": b[i + 1] = "X" r += 1 elif a[i] == "0" or b[i] == "0": if a[i + 1] == "0" and b[i + 1] == "0": a[i + 1] = "X" b[i + 1] = "X" r += 1 print(r)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
arr1 = list(input()) arr2 = list(input()) count = 0 for i in range(len(arr1) - 1): if arr1[i] == "0" and arr1[i + 1] == "0" and arr2[i] == "0": count += 1 arr1[i] = "X" arr1[i + 1] = "X" arr2[i] = "X" elif arr1[i] == "0" and arr1[i + 1] == "0" and arr2[i + 1] == "0": count += 1 arr1[i] = "X" arr1[i + 1] = "X" arr2[i + 1] = "X" elif arr2[i] == "0" and arr2[i + 1] == "0" and arr1[i] == "0": count += 1 arr2[i] = "X" arr2[i + 1] = "X" arr1[i] = "X" elif arr2[i] == "0" and arr2[i + 1] == "0" and arr1[i + 1] == "0": count += 1 arr2[i] = "X" arr2[i + 1] = "X" arr1[i + 1] = "X" print(count)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
board = [] for i in range(2): row = list(input()) board.append(row) n = len(row) empty = {} for i in range(n): if board[0][i] == "0" and board[1][i] == "0": empty[i] = 2 elif board[0][i] == "0" or board[1][i] == "0": empty[i] = 1 elif board[0][i] == "X" and board[1][i] == "X": empty[i] = 0 uec = 0 bish = 0 for i in range(n): current = empty[i] uec += current if uec >= 3: uec -= 3 bish += 1 else: uec = current print(bish)
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
b = [list(input()) for _ in range(2)] n = len(b[0]) ans = 0 a = [] for i in range(n): ai = 0 if b[0][i] == "0": ai += 1 if b[1][i] == "0": ai += 1 a.append(ai) prv = 0 for i in range(n): if a[i] == 0: prv = 0 elif a[i] == 1: if prv == 2: ans += 1 prv = 0 else: prv = 1 elif a[i] == 2: if prv == 2: ans += 1 prv = 1 elif prv == 1: ans += 1 prv = 0 else: prv = 2 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
def read_input(): return map(int, input().split()) a = [list(input()), list(input())] ans = 0 n = len(a[0]) i = 0 while i + 1 < n: cnt = sum(c == "X" for c in [a[0][i], a[1][i], a[0][i + 1], a[1][i + 1]]) if cnt > 1: i += 1 continue if cnt == 1: ans += 1 i += 2 continue ans += 1 a[0][i + 1] = "X" i += 1 print(ans)
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR STRING VAR LIST VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = [input(), input()] pc = [[s[0][i], s[1][i]].count("0") for i in range(len(s[0]))] ans = 0 for i in range(len(pc) - 1): if pc[i] >= 2 and pc[i + 1] >= 1: ans += 1 pc[i] -= 2 pc[i + 1] -= 1 elif pc[i] >= 1 and pc[i + 1] >= 2: ans += 1 pc[i] -= 1 pc[i + 1] -= 2 print(ans)
ASSIGN VAR LIST FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL LIST VAR NUMBER VAR VAR NUMBER VAR STRING VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
f = [] for i in range(2): f.append(list(input())) answer = 0 n = len(f[0]) for i in range(n): if f[0][i] == f[1][i] == "0" and i + 1 < n: if f[0][i + 1] == "0": answer += 1 f[0][i + 1] = "X" elif f[1][i + 1] == "0": answer += 1 f[1][i + 1] = "X" elif ( (f[1][i] == "0" or f[0][i] == "0") and i + 1 < n and f[0][i + 1] == f[1][i + 1] == "0" ): answer += 1 f[0][i + 1] = f[1][i + 1] = "X" print(answer)
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR STRING BIN_OP VAR NUMBER VAR IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING BIN_OP VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
line1 = input() line2 = input() n = len(line1) res = 0 ind = 0 while ind < n - 1: count = 0 if line1[ind] == "0": count += 1 if line1[ind + 1] == "0": count += 1 if line2[ind] == "0": count += 1 if line2[ind + 1] == "0": count += 1 if count == 3: res += 1 ind += 2 elif count == 4: res += 1 if ind + 2 <= n - 1: if line1[ind + 2] == "0" and line2[ind + 2] == "0": res += 1 ind += 3 else: ind += 2 else: ind += 2 else: ind += 1 print(res)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = list(input()) st = list(input()) c = 0 for i in range(len(s)): if i > 0: if s[i - 1] == st[i - 1] == "0": if s[i] == "0": s[i - 1] = "Y" st[i - 1] = "Y" s[i] = "Y" c += 1 elif st[i] == "0": s[i - 1] = "Y" st[i - 1] = "Y" st[i] = "Y" c += 1 if s[i] == st[i] == "0": if s[i - 1] == "0": s[i] = "Y" st[i] = "Y" s[i - 1] = "Y" c += 1 elif st[i - 1] == "0": s[i] = "Y" st[i] = "Y" st[i - 1] = "Y" c += 1 elif s[i] == "0": if s[i - 1] == st[i - 1] == "0": s[i - 1] = "Y" st[i - 1] = "Y" s[i] = "Y" c += 1 elif st[i] == "0": if s[i - 1] == st[i - 1] == "0": s[i - 1] = "Y" st[i - 1] = "Y" st[i] = "Y" c += 1 print(c)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING VAR NUMBER IF VAR VAR VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
l = list(input()) m = list(input()) count = 0 n = len(l) for i in range(len(l)): if l[i] == "0": if i + 1 < n and m[i] == "0" and m[i + 1] == "0": count += 1 l[i] = "X" m[i] = "X" m[i + 1] = "X" elif i - 1 >= 0 and m[i] == "0" and m[i - 1] == "0": count += 1 l[i] = "X" m[i] = "X" m[i - 1] = "X" elif i + 1 < n and l[i + 1] == "0" and m[i + 1] == "0": l[i] = "X" l[i + 1] = "X" m[i + 1] = "X" count += 1 elif i - 1 >= 0 and l[i - 1] == "0" and m[i - 1] == "0": l[i] = "X" l[i - 1] = "X" m[i - 1] = "X" count += 1 if m[i] == "0": if i + 1 < n and l[i] == "0" and l[i + 1] == "0": count += 1 m[i] = "X" l[i] = "X" l[i + 1] = "X" elif i - 1 >= 0 and l[i] == "0" and l[i - 1] == "0": count += 1 m[i] = "X" l[i] = "X" l[i - 1] = "X" elif i + 1 < n and m[i + 1] == "0" and l[i + 1] == "0": m[i] = "X" m[i + 1] = "X" l[i + 1] = "X" count += 1 elif i - 1 >= 0 and m[i - 1] == "0" and l[i - 1] == "0": m[i] = "X" m[i - 1] = "X" l[i - 1] = "X" count += 1 print(count)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR NUMBER VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING IF BIN_OP VAR NUMBER VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = [list(input()) for _ in range(2)] n = 0 for i in range(len(a[0])): bljet = 0 if a[0][i] == a[1][i] and a[0][i] == "0": if i > 0: if a[0][i - 1] == "0": a[0][i - 1] = "X" a[0][i] = "X" a[1][i] = "X" bljet = 1 if not bljet and a[1][i - 1] == "0": a[1][i - 1] = "X" a[0][i] = "X" a[1][i] = "X" bljet = 1 if i + 1 < len(a[0]): if not bljet and a[0][i + 1] == "0": a[0][i + 1] = "X" a[0][i] = "X" a[1][i] = "X" bljet = 1 if not bljet and a[1][i + 1] == "0": a[1][i + 1] = "X" a[0][i] = "X" a[1][i] = "X" bljet = 1 if bljet: n += 1 print(n)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR STRING IF VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER IF VAR VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER IF VAR VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s1 = list(input()) s2 = list(input()) i = 0 ans = 0 while i < len(s1) - 1: if s1[i] == "0" and s1[i + 1] == "0" and s2[i] == "0": s1[i] = "X" s1[i + 1] = "X" s2[i] = "X" ans += 1 elif s1[i] == "0" and s1[i + 1] == "0" and s2[i + 1] == "0": s1[i] = "X" s1[i + 1] = "X" s2[i + 1] = "X" ans += 1 elif s1[i] == "0" and s2[i] == "0" and s2[i + 1] == "0": s1[i] = "X" s2[i + 1] = "X" s2[i + 1] = "X" ans += 1 elif s1[i + 1] == "0" and s2[i] == "0" and s2[i + 1] == "0": s1[i + 1] = "X" s2[i] = "X" s2[i + 1] = "X" ans += 1 i += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a1 = list(input()) a2 = list(input()) c = 0 for i in range(len(a1) - 1): if a1[i] == "0" and a2[i] == "0" and a1[i + 1] == "0": c += 1 a1[i] = 1 a2[i] = 1 a1[i + 1] = 1 elif a1[i] == "0" and a2[i] == "0" and a2[i + 1] == "0": c += 1 a1[i] = 1 a2[i] = 1 a2[i + 1] = 1 elif a1[i + 1] == "0" and a2[i] == "0" and a2[i + 1] == "0": c += 1 a2[i] = 1 a1[i + 1] = 1 a2[i + 1] = 1 elif a1[i] == "0" and a2[i + 1] == "0" and a1[i + 1] == "0": c += 1 a1[i] = 1 a1[i + 1] = 1 a2[i + 1] = 1 print(c)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
str1 = input() str2 = input() l = len(str1) num = [] for i in range(0, l): num.append(0) if str1[i] == "0": num[i] = num[i] + 1 if str2[i] == "0": num[i] = num[i] + 1 now = 0 res = 0 for i in num: now = now + i if now >= 3: res = res + 1 now = now - 3 elif now <= 2 and i != 2: now = i print(res)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR BIN_OP VAR VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = input().strip() t = input().strip() length = len(s) l1 = [] l2 = [] for i in range(length): l1.append(s[i]) l2.append(t[i]) if length == 1: print(0) else: ans = 0 for i in range(length - 1): count = 0 save = -1, -1 if l1[i] == "X": count += 1 save = 0, i if l1[i + 1] == "X": count += 1 save = 0, i + 1 if l2[i] == "X": count += 1 save = 1, i if l2[i + 1] == "X": count += 1 save = 1, i + 1 if count == 0: l1[i] = "X" l2[i] = "X" l2[i + 1] = "X" ans += 1 elif count == 1: l1[i] = "X" l1[i + 1] = "X" l2[i] = "X" l2[i + 1] = "X" ans += 1 print(ans)
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
grid = [] grid.append(input().strip()) grid.append(input().strip()) temp = [] for char in grid[0]: temp.append(char) grid[0] = temp temp = [] for char in grid[1]: temp.append(char) grid[1] = temp n = len(grid[0]) count = 0 for i in range(n - 1): curr_grid = [] curr_grid.append(grid[0][i]) curr_grid.append(grid[0][i + 1]) curr_grid.append(grid[1][i]) curr_grid.append(grid[1][i + 1]) x = curr_grid.count("X") if x == 1: count += 1 grid[0][i] = "X" grid[0][i + 1] = "X" grid[1][i] = "X" grid[1][i + 1] = "X" elif x == 0: count += 1 grid[0][i] = "X" grid[1][i] = "X" grid[1][i + 1] = "X" print(count)
ASSIGN VAR LIST EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR ASSIGN VAR LIST FOR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
arr1 = input() arr2 = input() def replace(arr, index, element): for i in range(len(arr)): if i == index: arr[i] = element else: continue return arr arr1 = list(arr1) arr2 = list(arr2) c = 0 for i in range(len(arr1) - 1): if arr1[i] == "0" and arr2[i] == "0" and arr2[i + 1] == "0": c += 1 arr1 = replace(arr1, i, "X") arr2 = replace(arr2, i, "X") arr2 = replace(arr2, i + 1, "X") elif arr1[i] == "0" and arr1[i + 1] == "0" and arr2[i + 1] == "0": c += 1 arr1 = replace(arr1, i, "X") arr1 = replace(arr1, i + 1, "X") arr2 = replace(arr2, i + 1, "X") elif arr1[i] == "0" and arr1[i + 1] == "0" and arr2[i] == "0": c += 1 arr1 = replace(arr1, i, "X") arr1 = replace(arr1, i + 1, "X") arr2 = replace(arr2, i, "X") elif arr1[i + 1] == "0" and arr2[i + 1] == "0" and arr2[i] == "0": c += 1 arr1 = replace(arr1, i + 1, "X") arr2 = replace(arr2, i + 1, "X") arr2 = replace(arr2, i, "X") print(c)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s1 = list(input()) s2 = list(input()) s1 = ["X"] + s1 + ["X"] s2 = ["X"] + s2 + ["X"] ans = 0 for i in range(1, len(s1) - 1): if s1[i] == "0" and s2[i] == "0": if s1[i - 1] == "0": ans += 1 s1[i] = "X" s2[i] = "X" s1[i - 1] = "X" elif s2[i - 1] == "0": ans += 1 s1[i] = "X" s2[i] = "X" s2[i - 1] = "X" elif s1[i + 1] == "0": ans += 1 s1[i] = "X" s2[i] = "X" s1[i + 1] = "X" elif s2[i + 1] == "0": ans += 1 s1[i] = "X" s2[i] = "X" s2[i + 1] = "X" print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST STRING VAR LIST STRING ASSIGN VAR BIN_OP BIN_OP LIST STRING VAR LIST STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
num = [] num.append(list(i for i in input())) num.append(list(i for i in input())) ans = 0 for i in range(len(num[0]) - 1): if num[0][i] == "0" and num[1][i] == "0": if num[0][i + 1] == "0": ans += 1 num[0][i + 1] = "X" elif num[1][i + 1] == "0": ans += 1 num[1][i + 1] = "X" elif num[0][i + 1] == "0" and num[1][i + 1] == "0": if num[0][i] == "0" or num[1][i] == "0": ans += 1 num[0][i + 1] = "X" num[1][i + 1] = "X" print(ans)
ASSIGN VAR LIST EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
l1 = list(input()) l2 = list(input()) s = 0 while len(l1) > 2 and len(l2) > 2: if l1[0] == "X" and l2[0] == "X": l1.pop(0) l2.pop(0) elif l1[0] == "0" and l2[0] == "X": if l1[1] == "0" and l2[1] == "0": s += 1 l1.pop(1) l1.pop(0) l2.pop(1) l2.pop(0) elif l1[1] == "X" and l2[1] == "X": l1.pop(1) l1.pop(0) l2.pop(1) l2.pop(0) else: l1.pop(0) l2.pop(0) elif l1[0] == "X" and l2[0] == "0": if l1[1] == "0" and l2[1] == "0": s += 1 l1.pop(1) l1.pop(0) l2.pop(1) l2.pop(0) elif l1[1] == "X" and l2[1] == "X": l1.pop(1) l1.pop(0) l2.pop(1) l2.pop(0) else: l1.pop(0) l2.pop(0) elif l1[1] == "X" and l2[1] == "0" or l1[1] == "0" and l2[1] == "X": s += 1 l1.pop(1) l1.pop(0) l2.pop(1) l2.pop(0) elif l1[1] == "X" and l2[1] == "X": l1.pop(1) l1.pop(0) l2.pop(1) l2.pop(0) else: s += 1 l1[1] = "X" l2[1] = "0" l1.pop(0) l2.pop(0) if len(l1) == 2: if l1[0] == "0" and l2[0] == "0": if l1[1] == "0" or l2[1] == "0": s += 1 elif l1[0] == "0" and l2[0] == "X" or l1[0] == "X" and l2[0] == "0": if l1[1] == "0" and l2[1] == "0": s += 1 print(s)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING IF VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING IF VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING IF VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER STRING IF VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = ["", ""] a[0] = input() a[1] = input() n = len(a[0]) cnt = 0 if n > 1: d = 0 for i in range(n): b = 0 if a[0][i] == "0": b += 1 if a[1][i] == "0": b += 1 d += b if d > 2: cnt += 1 d = d - 3 else: d = b print(cnt) else: print(0)
ASSIGN VAR LIST STRING STRING ASSIGN VAR NUMBER FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = input() b = input() n = len(a) cana, canb = [True] * n, [True] * n ans = 0 for i in range(n - 1): if a[i] == b[i] == a[i + 1] == "0" and cana[i] & cana[i + 1] & canb[i] == True: ans += 1 cana[i] = cana[i + 1] = canb[i] = False elif a[i] == b[i] == b[i + 1] == "0" and cana[i] & canb[i + 1] & canb[i] == True: ans += 1 cana[i] = canb[i + 1] = canb[i] = False elif ( a[i + 1] == b[i] == b[i + 1] == "0" and cana[i + 1] & canb[i + 1] & canb[i] == True ): ans += 1 cana[i + 1] = canb[i + 1] = canb[i] = False elif ( a[i + 1] == a[i] == b[i + 1] == "0" and cana[i] & canb[i + 1] & cana[i + 1] == True ): ans += 1 cana[i] = canb[i + 1] = cana[i + 1] = False print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR BIN_OP VAR NUMBER STRING BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR VAR VAR BIN_OP VAR NUMBER STRING BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
in1 = input() in2 = input() s1 = [] s2 = [] for i in range(len(in1)): s1.append(in1[i]) for i in range(len(in2)): s2.append(in2[i]) n = 0 for i in range(len(s1) - 1): t = 0 a = s1[i] b = s1[i + 1] c = s2[i] d = s2[i + 1] if s1[i] == "0": t += 1 s1[i] = "X" if s2[i] == "0": t += 1 s2[i] = "X" if s1[i + 1] == "0": t += 1 s1[i + 1] = "X" if s2[i + 1] == "0": if t != 3: s2[i + 1] = "X" t += 1 if t >= 3: n += 1 else: s1[i] = a s1[i + 1] = b s2[i] = c s2[i + 1] = d print(n)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR STRING IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
from sys import stdin, stdout INF = float("-inf") a = [stdin.readline().strip(), stdin.readline().strip()] n = len(a[0]) dp = [[INF, INF, INF, INF] for i in range(n)] if a[0][0] + a[1][0] == "00": dp[0][0] = 0 if a[0][0] + a[1][0] == "X0": dp[0][1] = 0 if a[0][0] + a[1][0] == "0X": dp[0][2] = 0 if a[0][0] + a[1][0] == "XX": dp[0][3] = 0 for i in range(n - 1): if a[0][i + 1] + a[1][i + 1] == "00": dp[i + 1][0] = max(max(max(dp[i][0], dp[i][1]), dp[i][2]), dp[i][3]) dp[i + 1][1] = max(dp[i][0] + 1, dp[i + 1][1]) dp[i + 1][2] = max(dp[i][0] + 1, dp[i + 1][2]) dp[i + 1][3] = max(max(dp[i][1], max(dp[i][2], dp[i][0])) + 1, dp[i + 1][3]) elif a[0][i + 1] + a[1][i + 1] == "XX": dp[i + 1][3] = max(max(max(dp[i][0], dp[i][1]), dp[i][2]), dp[i][3]) elif a[0][i + 1] + a[1][i + 1] == "0X": dp[i + 1][2] = max(max(max(dp[i][0], dp[i][1]), dp[i][2]), dp[i][3]) dp[i + 1][3] = max(dp[i + 1][3], dp[i][0] + 1) elif a[0][i + 1] + a[1][i + 1] == "X0": dp[i + 1][1] = max(max(max(dp[i][0], dp[i][1]), dp[i][2]), dp[i][3]) dp[i + 1][3] = max(dp[i + 1][3], dp[i][0] + 1) ans = 0 for i in range(4): ans = max(ans, dp[n - 1][i]) stdout.write(str(ans))
ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FUNC_CALL FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR VAR VAR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER STRING ASSIGN VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER STRING ASSIGN VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER STRING ASSIGN VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER STRING ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = [list(input()) for i in range(2)] n = len(s[0]) ans = 0 if n > 1: i = 0 if s[0][i] == s[1][i] and s[0][i] != "X": if s[0][i] == s[0][i + 1]: ans += 1 s[0][i] = "X" s[1][i] = "X" s[0][i + 1] = "X" elif s[0][i] == s[1][i + 1]: ans += 1 s[0][i] = "X" s[1][i] = "X" s[1][i + 1] = "X" for i in range(1, n - 1): if s[0][i] != s[1][i] or s[0][i] == "X": continue if s[0][i] == s[0][i - 1]: ans += 1 s[0][i] = "X" s[1][i] = "X" s[0][i - 1] = "X" elif s[0][i] == s[1][i - 1]: ans += 1 s[0][i] = "X" s[1][i] = "X" s[1][i - 1] = "X" elif s[0][i] == s[0][i + 1]: ans += 1 s[0][i] = "X" s[1][i] = "X" s[0][i + 1] = "X" elif s[0][i] == s[1][i + 1]: ans += 1 s[0][i] = "X" s[1][i] = "X" s[1][i + 1] = "X" i = n - 1 if s[0][i] == s[1][i] and s[0][i] != "X": if s[0][i] == s[0][i - 1]: ans += 1 elif s[0][i] == s[1][i - 1]: ans += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR STRING IF VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR STRING IF VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR STRING IF VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
t1 = [i for i in input()] t2 = [i for i in input()] for i in range(len(t1)): if t1[i] == "X": t1[i] = 0 else: t1[i] = 1 if t2[i] == "X": t2[i] = 0 else: t2[i] = 1 def ans(t1, t2, i=0): if len(t1) <= 1: return i if t1[-1] + t2[-1] == 0: t1.pop() t2.pop() return ans(t1, t2, i) if t1[-2] + t1[-1] + t2[-2] + t2[-1] == 4: t1.pop() t2.pop() t1[-1] = 0 return ans(t1, t2, 1 + i) if t1[-2] + t1[-1] + t2[-2] + t2[-1] == 3: t1.pop() t1.pop() t2.pop() t2.pop() return ans(t1, t2, i + 1) if t1[-2] + t1[-1] + t2[-2] + t2[-1] <= 2: t1.pop() t2.pop() return ans(t1, t2, i) print(ans(t1, t2))
ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_DEF NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN VAR IF BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER RETURN FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR IF BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
(*l,) = map(list, zip(input(), input())) a = 0 for i in range(1, len(l)): if l[i - 1] == ["0", "0"]: if l[i] == ["0", "0"]: a += 1 l[i] = ["0", "X"] elif l[i] == ["0", "X"] or l[i] == ["X", "0"]: a += 1 l[i] = ["X", "X"] elif l[i - 1] == ["0", "X"] or l[i - 1] == ["X", "0"]: if l[i] == ["0", "0"]: a += 1 l[i] = ["X", "X"] print(a)
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER LIST STRING STRING IF VAR VAR LIST STRING STRING VAR NUMBER ASSIGN VAR VAR LIST STRING STRING IF VAR VAR LIST STRING STRING VAR VAR LIST STRING STRING VAR NUMBER ASSIGN VAR VAR LIST STRING STRING IF VAR BIN_OP VAR NUMBER LIST STRING STRING VAR BIN_OP VAR NUMBER LIST STRING STRING IF VAR VAR LIST STRING STRING VAR NUMBER ASSIGN VAR VAR LIST STRING STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
list1 = list(input()) list2 = list(input()) n = len(list1) count = 0 for i in range(n): if list1[i] == "0": if i > 0 and list1[i - 1] == "0" and list2[i - 1] == "0": count += 1 list1[i] = "X" list2[i - 1] = "x" list1[i - 1] = "x" elif i > 0 and list2[i] == "0" and list2[i - 1] == "0": count += 1 list1[i] = "x" list2[i] = "x" list2[i - 1] = "x" elif i > 0 and list2[i] == "0" and list1[i - 1] == "0": count += 1 list1[i] = "x" list2[i] = "x" list1[i - 1] = "x" elif i < n - 1 and list1[i] == "0" and list2[i] == "0" and list2[i + 1] == "0": count += 1 list1[i] = "x" list2[i] = "x" list2[i + 1] = "x" i += 1 print(count)
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 FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = [] a.append(input()) a.append(input()) dp = [-200] * 4 dp[1 * (a[0][0] == "X") + 2 * (a[1][0] == "X")] = 0 for i in range(1, len(a[0])): odp = dp dp = [-200] * 4 state = 1 * (a[0][i] == "X") + 2 * (a[1][i] == "X") for last_state in range(4): dp[state] = max(dp[state], odp[last_state]) if last_state != 3 and state == 0: dp[3] = max(dp[3], odp[last_state] + 1) if last_state == 0: if ~state & 1: dp[state + 1] = max(dp[state + 1], odp[last_state] + 1) if ~state & 2: dp[state + 2] = max(dp[state + 2], odp[last_state] + 1) print(max(max(dp[0], dp[1]), max(dp[2], dp[3])))
ASSIGN VAR LIST EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER STRING BIN_OP NUMBER VAR NUMBER NUMBER STRING NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR STRING BIN_OP NUMBER VAR NUMBER VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR NUMBER IF VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
l1 = [] l2 = [] for i in input(): l1.append(i) for i in input(): l2.append(i) count = 0 c = 0 while c < len(l1) - 1: newli = [l1[c], l1[c + 1], l2[c], l2[c + 1]] try: if l1[c] == l1[c + 1] == l1[c + 2] == l2[c] == l2[c + 1] == l2[c + 2] == "0": count += 2 c += 3 continue except: pass if newli.count("0") >= 3: count += 1 c += 2 else: c += 1 print(count)
ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF FUNC_CALL VAR STRING NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
chess, ans = [list(input()) for i in range(2)], 0 for i in range(len(chess[0])): if chess[0][i] == chess[1][i] == "0": if i > 0: if chess[0][i - 1] == "0": ans += 1 chess[0][i] = chess[1][i] = chess[0][i - 1] = "X" elif chess[1][i - 1] == "0": chess[0][i] = chess[1][i] = chess[1][i - 1] = "X" ans += 1 if chess[0][i] == chess[1][i] == "0": if i < len(chess[0]) - 1: if chess[0][i + 1] == "0": ans += 1 chess[0][i] = chess[1][i] = chess[0][i + 1] = "X" elif chess[1][i + 1] == "0": chess[0][i] = chess[1][i] = chess[1][i + 1] = "X" ans += 1 print(ans)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR STRING IF VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR STRING IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
def check(i): if s[0][i - 1] == s[1][i - 1] == s[1][i] == s[0][i] == "0": return 4 elif s[0][i - 1] == s[1][i - 1] == s[1][i] == "0": return 0 elif s[0][i - 1] == s[1][i - 1] == s[0][i] == "0": return 1 elif s[0][i] == s[1][i] == s[0][i - 1] == "0": return 2 elif s[0][i] == s[1][i] == s[1][i - 1] == "0": return 3 return -1 s = [input(), input()] n = len(s[0]) dp = [([0] * 4) for i in range(n + 1)] for i in range(1, n): x = check(i) if x == 4 or x == 0: dp[i][0] = max(dp[i - 2]) + 1 if x == 4 or x == 1: dp[i][1] = max(dp[i - 2]) + 1 if x == 4 or x == 2: dp[i][2] = max(max(dp[i - 2]), dp[i - 1][0]) + 1 if x == 4 or x == 3: dp[i][3] = max(max(dp[i - 2]), dp[i - 1][1]) + 1 if x != 4: for j in range(4): if j != x: dp[i][j] = max(dp[i - 1][j], dp[i - 2][j]) print(max(dp[-2]))
FUNC_DEF IF VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR STRING RETURN NUMBER IF VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR STRING RETURN NUMBER IF VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR STRING RETURN NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER STRING RETURN NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER STRING RETURN NUMBER RETURN NUMBER ASSIGN VAR LIST FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a2 = input() b2 = input() a = [] b = [] for i in range(len(a2)): a.append(a2[i]) b.append(b2[i]) k = 0 for i in range(len(a)): if i == 0 and len(a) > 1: if a[0] == "0" and b[0] == "0" and a[1] == "0": a[0] = "X" b[0] = "X" a[1] = "X" k += 1 elif a[0] == "0" and b[0] == "0" and b[1] == "0": a[0] = "X" b[0] = "X" b[1] = "X" k += 1 elif i == len(a) - 1 and len(a) > 1: if a[i] == "0" and b[i] == "0" and a[i - 1] == "0": a[i] = "X" b[i] = "X" a[i - 1] = "X" k += 1 elif a[i] == "0" and b[i] == "0" and b[i - 1] == "0": a[i] = "X" b[i] = "X" b[i - 1] = "X" k += 1 elif len(a) > 1: if a[i] == "0" and b[i] == "0" and a[i - 1] == "0": a[i] = "X" b[i] = "X" a[i - 1] = "X" k += 1 elif a[i] == "0" and b[i] == "0" and b[i - 1] == "0": a[i] = "X" b[i] = "X" b[i - 1] = "X" k += 1 elif a[i] == "0" and b[i] == "0" and a[i + 1] == "0": a[i] = "X" b[i] = "X" a[i + 1] = "X" k += 1 elif a[i] == "0" and b[i] == "0" and b[i + 1] == "0": a[i] = "X" b[i] = "X" b[i + 1] = "X" k += 1 else: k = 0 print(k)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
A = [] A += [input()] A += [input()] n = len(A[0]) B = [[(0) for _ in range(4)] for _ in range(n + 1)] B[0][0] = -1000 B[0][1] = -1000 B[0][2] = -1000 B[0][3] = 0 for i in range(1, n + 1): if A[1][i - 1] == "X": B[i][0] = -1000 elif A[0][i - 1] == "X": B[i][0] = max([B[i - 1][j] for j in range(4)]) else: B[i][0] = max([B[i - 1][2] + 1] + [B[i - 1][0], B[i - 1][1], B[i - 1][3]]) if A[0][i - 1] == "X": B[i][1] = -1000 elif A[1][i - 1] == "X": B[i][1] = max([B[i - 1][j] for j in range(4)]) else: B[i][1] = max([B[i - 1][2] + 1] + [B[i - 1][0], B[i - 1][1], B[i - 1][3]]) if A[0][i - 1] == "X" or A[1][i - 1] == "X": B[i][2] = -1000 else: B[i][2] = max([B[i - 1][j] for j in range(4)]) if A[0][i - 1] == "X" and A[1][i - 1] == "X": B[i][3] = max([B[i - 1][j] for j in range(4)]) elif A[0][i - 1] == "X": B[i][3] = B[i - 1][2] + 1 elif A[1][i - 1] == "X": B[i][3] = B[i - 1][2] + 1 else: B[i][3] = max([B[i - 1][j] for j in range(3)]) + 1 print(max([B[n][j] for j in range(4)]))
ASSIGN VAR LIST VAR LIST FUNC_CALL VAR VAR LIST FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR BIN_OP LIST BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER LIST VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR BIN_OP LIST BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER LIST VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR NUMBER
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
first = list(input()) second = list(input()) n = len(first) ans = 0 for i in range(n - 1): if first[i] == "0" and first[i + 1] == "0" and second[i] == "0": first[i] = "X" first[i + 1] = "X" second[i] = "X" ans = ans + 1 elif first[i] == "0" and first[i + 1] == "0" and second[i + 1] == "0": first[i] = "X" first[i + 1] = "X" second[i + 1] = "X" ans = ans + 1 elif first[i] == "0" and second[i] == "0" and second[i + 1] == "0": first[i] = "X" second[i] = "X" second[i + 1] = "X" ans = ans + 1 elif first[i] == "0" and second[i] == "0" and second[i + 1] == "0": first[i] = "X" second[i] = "X" second[i + 1] = "X" ans = ans + 1 elif first[i + 1] == "0" and second[i] == "0" and second[i + 1] == "0": first[i + 1] = "X" second[i] = "X" second[i + 1] = "X" ans = ans + 1 print(ans)
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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
import time s1 = input() s2 = input() start = time.time() n = len(s1) ans = 0 flag = 0 for i in range(n): if s1[i] != "0" and s2[i] != "0": flag = 0 continue if flag == 0: if s1[i] == "0" and s2[i] == "0": flag = 2 elif s1[i] == "0" or s2[i] == "0": flag = 1 elif flag == 1: if s1[i] == "0" and s2[i] == "0": ans += 1 flag = 0 else: ans += 1 if s1[i] == "0" and s2[i] == "0": flag = 1 else: flag = 0 print(ans) finish = time.time()
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
ans = 0 ch1 = ["1"] * 150 ch2 = ["1"] * 150 t1 = list(input()) t2 = list(input()) len1 = len(t1) for i in range(len1): ch1[i] = t1[i] ch2[i] = t2[i] for i in range(len1): if ch1[i] == "0" and ch2[i] == "0" and ch1[i + 1] == "0": ch1[i] = ch1[i + 1] = ch2[i] = "x" ans += 1 elif ch1[i] == "0" and ch2[i] == "0" and ch2[i + 1] == "0": ch1[i] = ch2[i] = ch2[i + 1] = "x" ans += 1 elif ch1[i] == "0" and ch1[i + 1] == "0" and ch2[i + 1] == "0": ch1[i] = ch1[i + 1] = ch2[i + 1] = "x" ans += 1 elif ch2[i] == "0" and ch1[i + 1] == "0" and ch2[i + 1] == "0": ch2[i] = ch1[i + 1] = ch2[i + 1] = "x" ans += 1 print(ans)
ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST STRING NUMBER ASSIGN VAR BIN_OP LIST STRING NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s1 = input() s2 = input() dp = [(0) for i in range(len(s1))] if s1[0] == s2[0] and s1[0] == "0": r = 2 elif s1[0] == s2[0] and s1[0] == "X": r = 0 else: r = 1 for i in range(1, len(s1)): if s1[i] == s2[i] and s1[i] == "X": dp[i] = dp[i - 1] r = 0 elif s1[i] != s2[i] and r <= 1: dp[i] = dp[i - 1] r = 1 elif s1[i] == s2[i] and s1[i] == "0": if r == 2: dp[i] = dp[i - 1] + 1 r = 1 elif r == 1: dp[i] = dp[i - 1] + 1 r = 0 else: dp[i] = dp[i - 1] r = 2 else: dp[i] = dp[i - 1] + 1 r = 0 print(dp[len(s1) - 1])
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR STRING ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
l1 = [c for c in input()] l2 = [c for c in input()] l = len(l1) total = 0 for x in range(l - 1): if l1[x] == "0" and l1[x + 1] == "0": if l2[x] == "0": l2[x] = "X" l1[x] = "X" l1[x + 1] = "X" total += 1 elif l2[x + 1] == "0": l2[x + 1] = "X" l1[x] = "X" l1[x + 1] = "X" total += 1 elif l2[x] == "0" and l2[x + 1] == "0": if l1[x] == "0": l1[x] = "X" l2[x] = "X" l2[x + 1] = "X" total += 1 elif l1[x + 1] == "0": l1[x + 1] = "X" l2[x] = "X" l2[x + 1] = "X" total += 1 print(total)
ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
t = input() b = input() n = len(t) ta = [(c == "0") for c in t] ba = [(c == "0") for c in b] cnt = 0 for i in range(n - 1): if ta[i] and ta[i + 1] and ba[i]: cnt += 1 ta[i] = ta[i + 1] = ba[i] = False if ta[i] and ba[i + 1] and ba[i]: cnt += 1 ta[i] = ba[i + 1] = ba[i] = False if ta[i] and ta[i + 1] and ba[i + 1]: cnt += 1 ta[i] = ta[i + 1] = ba[i + 1] = False if ta[i + 1] and ba[i] and ba[i + 1]: cnt += 1 ta[i + 1] = ba[i] = ba[i + 1] = False print(cnt)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING VAR VAR ASSIGN VAR VAR STRING VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return list(mi()) ss = [input().strip(), input().strip()] s = [(a + b) for a, b in zip(ss[0], ss[1])] + ["XX"] n = len(s) def solve(i, j): c = 0 k = i while k < j - 1: if s[k] == "0X" and s[k + 1] == "00": c += 1 k += 2 elif s[k] == "X0" and s[k + 1] == "00": c += 1 k += 2 elif s[k] == "00" and s[k + 1] == "X0": c += 1 k += 2 elif s[k] == "00" and s[k + 1] == "0X": c += 1 k += 2 elif s[k] == "00" and s[k + 1] == "00": c += 1 s[k + 1] = "0X" k += 1 else: k += 1 return c i = 0 c = 0 while i < n: if s[i] == "XX": i += 1 continue j = i + 1 while s[j] != "XX": j += 1 c += solve(i, j) i = j print(c)
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER LIST STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = [] a.append(["X"] + list(input()) + ["X"]) n = len(a[0]) a.append(["X"] + list(input()) + ["X"]) cnt = 0 for i in range(1, n): if a[0][i] == "0" and a[1][i] == "0": if a[0][i - 1] == "0": cnt += 1 a[0][i - 1] = "X" a[0][i] = "X" a[1][i] = "X" continue elif a[1][i - 1] == "0": cnt += 1 a[1][i - 1] = "X" a[0][i] = "X" a[1][i] = "X" continue elif a[0][i + 1] == "0": cnt += 1 a[0][i + 1] = "X" a[0][i] = "X" a[1][i] = "X" continue elif a[1][i + 1] == "0": cnt += 1 a[1][i + 1] = "X" a[0][i] = "X" a[1][i] = "X" continue print(cnt)
ASSIGN VAR LIST EXPR FUNC_CALL VAR BIN_OP BIN_OP LIST STRING FUNC_CALL VAR FUNC_CALL VAR LIST STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP LIST STRING FUNC_CALL VAR FUNC_CALL VAR LIST STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
f = lambda x: int(x == "0") arr = [(c1 + c2) for c1, c2 in zip(map(f, input()), map(f, input()))] res = 0 for i in range(len(arr) - 1): if arr[i] + arr[i + 1] >= 3: res += 1 arr[i], arr[i + 1] = 0, arr[i] + arr[i + 1] - 3 print(res)
ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
x = input() y = input() num = 0 t = 0 for i in range(len(x) - 1): count = 0 if x[i] == "0": count += 1 if x[i + 1] == "0": count += 1 if y[i] == "0": count += 1 if y[i + 1] == "0": count += 1 if count >= 3: num += 1 count = 0 if x[i] == "0": count += 1 x = x[:i] + "1" + x[i + 1 :] if y[i] == "0": count += 1 y = y[:i] + "1" + y[i + 1 :] if x[i + 1] == "0": count += 1 x = x[: i + 1] + "1" + x[i + 2 :] if y[i + 1] == "0" and count < 3: y = y[: i + 1] + "1" + y[i + 2 :] print(num)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s1 = input().strip() s2 = input().strip() n = len(s1) c = 0 i = 0 while i < n - 1: a = s1[i : i + 2] b = s2[i : i + 2] if a == "00" and b == "0X": c += 1 i += 2 elif a == "X0" and b == "00": c += 1 i += 2 elif a == "0X" and b == "00": c += 1 i += 2 elif a == "00" and b == "X0": c += 1 i += 2 elif a == "00" and b == "00": c += 1 if i < n - 2 and s1[i + 2] == "0" and s2[i + 2] == "0": i += 1 c += 1 i += 2 else: i += 1 print(c)
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR STRING VAR NUMBER VAR NUMBER IF VAR STRING VAR STRING VAR NUMBER VAR NUMBER IF VAR STRING VAR STRING VAR NUMBER VAR NUMBER IF VAR STRING VAR STRING VAR NUMBER VAR NUMBER IF VAR STRING VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = "X" + input() t = "X" + input() ans = 0 n = len(s) left = 0 for i in range(1, n): count = 0 if s[i] == "0": count += 1 if t[i] == "0": count += 1 if count + left >= 3: ans += 1 left = count + left - 3 else: left = count print(ans)
ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
ss = [input().strip() for _ in range(2)] n = len(ss[0]) cnt = 0 had1 = False had2 = False for i in range(n): ccur = sum(s[i] == "0" for s in ss) if ccur == 2: if had1: cnt += 1 had1 = False elif had2: cnt += 1 had2 = False had1 = True else: had2 = True elif ccur == 1: if had1: had1 = True elif had2: cnt += 1 had2 = False else: had1 = True else: had1 = False had2 = False print(cnt)
ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR STRING VAR VAR IF VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = input() t = input() m = [list(s), list(t)] i = 0 ans = 0 while i < len(s) - 1: indexes = [(0, i), (1, i), (0, i + 1), (1, i + 1)] for j in range(3, -1, -1): flag = True for k in range(4): if k != j: x = indexes[k] if m[x[0]][x[1]] == "X": flag = False break if flag: for k in range(4): if k != j: x = indexes[k] m[x[0]][x[1]] = "X" ans += 1 break i += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST NUMBER VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER STRING VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
r1 = input() r2 = input() n = len(r1) l = [0] for i in range(n): if r1[i] == "0": if r2[i] == "0": l.append(2) else: l.append(1) elif r2[i] == "X": l.append(0) else: l.append(-1) l.append(0) s = len(l) count = 0 u = 1 e = 1 while u < s - 1: if l[u] == 2 and e == 1: if l[u + 1] == 2: e = 2 u = u + 1 continue elif l[u + 1] == 1 or l[u + 1] == -1: count = count + 1 u = u + 2 continue else: u = u + 2 continue if l[u] == 2 and e == 2: if l[u + 1] == 2: count = count + 2 u = u + 2 e = 1 continue else: count = count + 1 u = u + 1 e = 1 continue if l[u] == 1 or l[u] == -1: if l[u + 1] == 2: count = count + 1 u = u + 2 continue else: u = u + 1 continue if l[u] == 0: u = u + 1 print(count)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
board = [] for i in range(2): board.append([(i == "0") for i in input()]) before_up = False before_down = False s = 0 for i in range(len(board[0])): if before_up and before_down: if board[0][i]: s += 1 before_up = False before_down = board[1][i] elif board[1][i]: s += 1 before_down = False before_up = board[0][i] else: before_up = False before_down = False elif before_up or before_down: if board[0][i] and board[1][i]: s += 1 before_up = False before_down = False else: before_up = board[0][i] before_down = board[1][i] else: before_up = board[0][i] before_down = board[1][i] print(s)
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR STRING VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
ar = [] cur = list(input()) ar.append(cur) cur = list(input()) ar.append(cur) count = 0 n = len(cur) if n == 1: print(0) else: for i in range(n): if ar[0][i] == "X": continue if i == 0: if ar[1][i] == "0" and ar[1][i + 1] == "0" and ar[0][i] == "0": count += 1 ar[1][i] = "X" ar[1][i + 1] = "X" ar[0][i] = "X" elif ar[0][i + 1] == "0" and ar[1][i + 1] == "0" and ar[0][i] == "0": count += 1 ar[0][i + 1] = "X" ar[1][i + 1] = "X" ar[0][i] = "X" elif i == n - 1: if ar[0][i - 1] == "0" and ar[1][i - 1] == "0" and ar[0][i] == "0": count += 1 ar[0][i - 1] = "X" ar[1][i - 1] = "X" ar[0][i] = "X" if ar[1][i] == "0" and ar[1][i - 1] == "0" and ar[0][i] == "0": count += 1 ar[1][i] = "X" ar[1][i - 1] = "X" ar[0][i] = "X" else: if ar[0][i - 1] == "0" and ar[1][i - 1] == "0" and ar[0][i] == "0": count += 1 ar[0][i - 1] = "X" ar[1][i - 1] = "X" ar[0][i] = "X" if ar[1][i] == "0" and ar[1][i - 1] == "0" and ar[0][i] == "0": count += 1 ar[1][i] = "X" ar[1][i - 1] = "X" ar[0][i] = "X" if ar[1][i] == "0" and ar[1][i + 1] == "0" and ar[0][i] == "0": count += 1 ar[1][i] = "X" ar[1][i + 1] = "X" ar[0][i] = "X" if ar[0][i + 1] == "0" and ar[1][i + 1] == "0" and ar[0][i] == "0": count += 1 ar[0][i + 1] = "X" ar[1][i + 1] = "X" ar[0][i] = "X" for i in range(n): if ar[1][i] == "X": continue if i == 0: if ar[0][i] == "0" and ar[0][i + 1] == "0" and ar[1][i] == "0": count += 1 ar[0][i] = "X" ar[0][i + 1] = "X" ar[1][i] = "X" if ar[0][i + 1] == "0" and ar[1][i + 1] == "0" and ar[1][i] == "0": count += 1 ar[0][i + 1] = "X" ar[1][i + 1] = "X" ar[1][i] = "X" elif i == n - 1: if ar[0][i - 1] == "0" and ar[1][i - 1] == "0" and ar[1][i] == "0": count += 1 ar[0][i - 1] = "X" ar[1][i - 1] = "X" ar[1][i] = "X" if ar[0][i] == "0" and ar[0][i - 1] == "0" and ar[1][i] == "0": count += 1 ar[0][i] = "X" ar[0][i - 1] = "X" ar[1][i] = "X" else: if ar[0][i - 1] == "0" and ar[1][i - 1] == "0" and ar[1][i] == "0": count += 1 ar[0][i - 1] = "X" ar[1][i - 1] = "X" ar[1][i] = "X" if ar[0][i] == "0" and ar[0][i - 1] == "0" and ar[1][i] == "0": count += 1 ar[0][i] = "X" ar[0][i - 1] = "X" ar[1][i] = "X" if ar[0][i] == "0" and ar[0][i + 1] == "0" and ar[1][i] == "0": count += 1 ar[0][i] = "X" ar[0][i + 1] = "X" ar[1][i] = "X" if ar[0][i + 1] == "0" and ar[1][i + 1] == "0" and ar[1][i] == "0": count += 1 ar[0][i + 1] = "X" ar[1][i + 1] = "X" ar[1][i] = "X" print(count)
ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING IF VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR BIN_OP VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING IF VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR BIN_OP VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
A = list(input()) B = list(input()) n = 0 for i in range(0, len(A) - 1): if A[i] == "0" and B[i] == "0": if A[i + 1] == "0": A[i + 1] = "X" A[i] = "X" B[i] = "X" n += 1 elif B[i + 1] == "0": B[i + 1] = "X" A[i] = "X" B[i] = "X" n += 1 elif A[i + 1] == "0" and B[i + 1] == "0": if A[i] == "0": A[i + 1] = "X" B[i + 1] = "X" A[i] = "X" n += 1 elif B[i] == "0": A[i + 1] = "X" B[i + 1] = "X" B[i] = "X" n += 1 print(n)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = [list(input()), list(input())] ans = 0 for i in range(len(s[0]) - 1): if s[1][i] == s[0][i] == "0": if s[0][i + 1] == "0": ans += 1 s[0][i] = s[0][i + 1] = s[1][i] = "X" elif s[1][i + 1] == "0": ans += 1 s[0][i] = s[1][i + 1] = s[1][i] = "X" if s[1][i + 1] == s[0][i + 1] == "0": if s[0][i] == "0": ans += 1 s[0][i] = s[0][i + 1] = s[1][i + 1] = "X" elif s[1][i] == "0": ans += 1 s[1][i + 1] = s[0][i + 1] = s[1][i] = "X" print(ans)
ASSIGN VAR LIST FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR NUMBER VAR VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
top = list(input()) bottom = list(input()) length = len(top) count = 0 i = 0 while i + 1 < length: if top[i] == "0" and bottom[i] == "0": if top[i + 1] == "0": count += 1 top[i + 1] = "X" i += 1 elif bottom[i + 1] == "0": count += 1 bottom[i + 1] = "X" i += 1 else: i += 2 elif top[i + 1] == "0" and bottom[i + 1] == "0": if top[i] == "0" or bottom[i] == "0": count += 1 i += 2 else: i += 1 else: i += 1 print(count)
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 WHILE BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
lis = [] n = 0 for i in range(2): s = list(input()) n = len(s) lis.append(s) ans = 0 for i in range(1, n): if lis[0][i - 1] == "0" and lis[1][i - 1] == "0" and lis[1][i] == "0": lis[0][i - 1] = "X" lis[1][i - 1] = "X" lis[1][i] = "X" ans += 1 elif lis[0][i - 1] == "0" and lis[0][i] == "0" and lis[1][i] == "0": ans += 1 lis[0][i - 1] = "X" lis[0][i] = "X" lis[1][i] = "X" elif lis[0][i - 1] == "0" and lis[0][i] == "0" and lis[1][i - 1] == "0": ans += 1 lis[0][i - 1] = "X" lis[0][i] = "X" lis[1][i - 1] = "X" elif lis[0][i] == "0" and lis[1][i - 1] == "0" and lis[1][i] == "0": ans += 1 lis[0][i] = "X" lis[1][i - 1] = "X" lis[1][i] = "X" print(ans)
ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
def check(a, i, h): t = 0 for j in range(2): if a[j][i] == "0": t += 1 if a[j][h] == "0": t += 1 if t >= 3: b = 0 for j in range(2): if a[j][i] == "0": b += 1 a[j][i] = "x" if a[j][h] == "0" and b != 3: b += 1 a[j][h] = "x" return 1 else: return 0 a = [] for i in range(2): t = str(input()) t = [j for j in t] a.append(t) count = 0 for i in range(len(a[0]) - 1): count += check(a, i, i + 1) print(count)
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR STRING VAR NUMBER IF VAR VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR STRING IF VAR VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR STRING RETURN NUMBER RETURN NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = [] m = 0 n = 2 for i in range(0, n): s.append(input()) m = len(s[i]) n = m ans = 0 empty = 0 for i in range(0, n): current = int((s[0][i] == "0") + (s[1][i] == "0")) empty += current if empty >= 3: empty -= 3 ans += 1 else: empty = current print(ans)
ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR STRING VAR NUMBER VAR STRING VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
fig1 = (1, 1), (0, 1) fig2 = (1, 1), (1, 0) fig3 = (0, 1), (1, 1) fig4 = (1, 0), (1, 1) def place(fig, grid): if len(grid[0]) < 2: return False, grid copygrid = [grid[0][:], grid[1][:]] for r in range(2): for c in range(2): copygrid[r][c] += fig[r][c] if copygrid[r][c] > 1: return False, grid return True, copygrid def shiftgrid(grid): return [grid[0][1:], grid[1][1:]] def cachekey(grid): return tuple(grid[0]), tuple(grid[1]) cache = {} def place_no(grid): if len(grid[0]) < 2: return 0 key = cachekey(grid) if key in cache: return cache[key] options = [] for fig in (fig1, fig2, fig3, fig4): placed, newgrid = place(fig, grid) options.append(int(placed) + place_no(shiftgrid(newgrid))) options.append(place_no(shiftgrid(grid))) rv = max(options) cache[key] = rv return rv def main(): grid = [] grid.append([(0 if c == "0" else 1) for c in input().strip()]) grid.append([(0 if c == "0" else 1) for c in input().strip()]) print(place_no(grid)) main()
ASSIGN VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER NUMBER FUNC_DEF IF FUNC_CALL VAR VAR NUMBER NUMBER RETURN NUMBER VAR ASSIGN VAR LIST VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER RETURN NUMBER VAR RETURN NUMBER VAR FUNC_DEF RETURN LIST VAR NUMBER NUMBER VAR NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT FUNC_DEF IF FUNC_CALL VAR VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR STRING NUMBER NUMBER VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR STRING NUMBER NUMBER VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = list(input()) s1 = list(input()) m = [s, s1] ans = c = 0 n = len(s) for i in range(0, n - 1): a = "" a += m[0][i] a += m[0][i + 1] a += m[1][i] a += m[1][i + 1] j = a.count("0") if j == 3: c += 1 m[0][i] = "-1" m[0][i + 1] = "-1" m[1][i] = "-1" m[1][i + 1] = "-1" if j == 4: c += 1 m[0][i] = "-1" m[1][i] = "-1" m[1][i + 1] = "-1" print(c)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR STRING VAR VAR NUMBER VAR VAR VAR NUMBER BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = input(), input() c = 0 for s in filter( None, "".join( str(min(2, sum(x[i : i + 2].count("X") for x in s))) for i in range(len(s[0]) - 1) ).split("2"), ): a, b = ([*filter(None, map(len, s.split(c)))] for c in "01") if s[0] < "1": a = [0] + a if s[-1] > "0": b += [0] k = 1 for x, y in zip(a, b): x += k if y: x -= 1 y += 1 k = y % 3 if x % 2 and k > 0: x += 1 k -= 1 c += x // 2 + y // 3 * 2 c += k // 2 print(c)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NONE FUNC_CALL FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER STRING ASSIGN VAR VAR LIST FUNC_CALL VAR NONE FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR STRING IF VAR NUMBER STRING ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER STRING VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
l1 = list(input().strip()) l2 = list(input().strip()) r = 0 for i in range(len(l1) - 1): if l1[i] == "0" and l2[i] == "0": if l2[i + 1] == "0": l1[i] = "X" l2[i] = "X" l2[i + 1] = "X" r += 1 elif l1[i + 1] == "0": l1[i] = "X" l2[i] = "X" l1[i + 1] = "X" r += 1 elif l1[i] == "0": if l1[i + 1] == "0" and l2[i + 1] == "0": l1[i] = "X" l1[i + 1] = "X" l2[i + 1] = "X" r += 1 elif l2[i] == "0": if l1[i + 1] == "0" and l2[i + 1] == "0": l2[i] = "X" l1[i + 1] = "X" l2[i + 1] = "X" r += 1 print(r)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = list(input()) b = list(input()) n = len(a) ans = 0 for i in range(n - 1): if a[i + 1] == "0" and a[i] == "0" and b[i] == "0": ans += 1 a[i] = a[i + 1] = b[i] = "X" elif b[i + 1] == "0" and a[i] == "0" and b[i] == "0": ans += 1 a[i] = b[i + 1] = b[i] = "X" elif b[i + 1] == "0" and a[i + 1] == "0" and b[i] == "0": ans += 1 a[i + 1] = b[i + 1] = b[i] = "X" elif b[i + 1] == "0" and a[i + 1] == "0" and a[i] == "0": ans += 1 a[i + 1] = b[i + 1] = a[i] = "X" print(ans)
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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = [] counter = 0 def checar(): global s global counter for x in range(len(s[0])): if s[0][x] == "0": if s[1][x] == "0": if x > 0 and s[1][x - 1] == "0": s[0][x] = "X" s[1][x] = "X" s[1][x - 1] = "X" counter += 1 continue elif x < len(s[0]) - 1 and s[1][x + 1] == "0": s[0][x] = "X" s[1][x] = "X" s[1][x + 1] = "X" counter += 1 continue elif x < len(s[0]) - 1 and s[0][x + 1] == "0": s[0][x] = "X" s[1][x] = "X" s[0][x + 1] = "X" counter += 1 continue elif x < len(s[0]) - 1 and s[0][x + 1] == "0" and s[1][x + 1] == "0": s[0][x] = "X" s[0][x + 1] = "X" s[1][x + 1] = "X" counter += 1 continue s.append(list(input())) s.append(list(input())) checar() print(counter)
ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR STRING IF VAR NUMBER VAR STRING IF VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
n = list(input()) p = list(input()) t = len(n) count = 0 for i in range(t - 1): if n[i] == "0" and p[i] == "0" and p[i + 1] == "0": count = count + 1 n[i] = "X" p[i] = "X" p[i + 1] = "X" elif n[i] == "0" and p[i] == "0" and n[i + 1] == "0": count = count + 1 n[i] = "X" p[i] = "X" n[i + 1] = "X" elif n[i] == "0" and n[i + 1] == "0" and p[i + 1] == "0": count = count + 1 n[i + 1] = "X" n[i] = "X" p[i + 1] = "X" elif p[i] == "0" and n[i + 1] == "0" and p[i + 1] == "0": count = count + 1 n[i + 1] = "X" p[i] = "X" p[i + 1] = "X" print(count)
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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = list(input()) b = list(input()) l = len(a) ans = 0 i = 0 while i < l - 1: if i + 2 < l: if not "X" in a[i : i + 3] and not "X" in b[i : i + 3]: i += 3 ans += 2 continue if a[i] == "0" and b[i] == "0": if a[i + 1] == "0" or b[i + 1] == "0": ans += 1 i += 2 continue if a[i] == "0" or b[i] == "0": if a[i + 1] == "0" and b[i + 1] == "0": ans += 1 i += 2 continue i += 1 print(ans)
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 WHILE VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR IF STRING VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
l, r = [{"0": 1, "X": 0}[c] for cc in zip(input(), input()) for c in cc], 0 for i in range(0, len(l) - 3, 2): s = 7 - sum(l[i : i + 4]) if s < 5: r += 1 l[i : i + s] = [0] * s print(r)
ASSIGN VAR VAR DICT STRING STRING NUMBER NUMBER VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = [] for i in range(2): a.append(input()) ans, cnt, cur = 0, 0, 0 n = len(a[0]) for i in range(n): cnt = (a[0][i] == "0") + (a[1][i] == "0") cur += cnt if cur >= 3: cur -= 3 ans += 1 else: cur = cnt print(ans)
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR STRING VAR NUMBER VAR STRING VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
row1 = input() row2 = input() n = len(row1) flag = None for i in range(n): if row1[i] == "0" and row2[i] == "0": flag = 1 break elif row1[i] == "0" or row2[i] == "0": flag = 2 break zeros = 0 ans = 0 for i in range(1, n): if flag == None: if row1[i] == "0" and row2[i] == "0": flag = 1 elif row1[i] == "0" or row2[i] == "0": flag = 2 continue if row1[i] == row2[i] == "0": if flag == 2: ans += 1 zeros = 0 flag = None else: zeros += 1 elif flag == 1: if (zeros + 1) % 3 == 0: ans += (zeros + 1) // 3 * 2 elif (zeros + 1) % 3 == 2: ans += (zeros + 1) // 3 * 2 + 1 elif row1[i] != row2[i]: ans += (zeros + 1) // 3 * 2 + 1 flag = None zeros = 0 continue else: ans += (zeros + 1) // 3 * 2 flag = 2 if row1[i] == row2[i]: flag = None else: flag = 2 zeros = 0 elif row1[i] == row2[i]: flag = None if flag == 1: if (zeros + 1) % 3 == 0 or (zeros + 1) % 3 == 1: ans += (zeros + 1) // 3 * 2 elif (zeros + 1) % 3 == 2: ans += (zeros + 1) // 3 * 2 + 1 elif flag == 2 and zeros == 1: ans += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NONE IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER IF VAR VAR VAR VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE VAR NUMBER IF VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF VAR VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NONE ASSIGN VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR NONE ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR NONE IF VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
topboard = list(input()) botboard = list(input()) bish = 0 left = 0 while left + 1 < len(topboard): if topboard[left] == "0" and botboard[left] == "0": if topboard[left + 1] == "0": bish += 1 topboard[left] = "X" topboard[left + 1] = "X" botboard[left] = "X" elif botboard[left + 1] == "0": bish += 1 topboard[left] = "X" botboard[left] = "X" botboard[left + 1] = "X" elif topboard[left + 1] == "0" and botboard[left + 1] == "0": if topboard[left] == "0": bish += 1 topboard[left] = "X" topboard[left + 1] = "X" botboard[left + 1] = "X" elif botboard[left] == "0": bish += 1 topboard[left + 1] = "X" botboard[left] = "X" botboard[left + 1] = "X" left += 1 print(bish)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = list(input()) b = list(input()) counter = 0 for i in range(1, len(a)): if a[i - 1] == "0" and a[i] == "0" and b[i - 1] == "0": a[i - 1] = "X" a[i] = "X" b[i - 1] = "X" counter += 1 elif a[i - 1] == "0" and a[i] == "0" and b[i] == "0": a[i - 1] = "X" a[i] = "X" b[i] = "X" counter += 1 elif b[i - 1] == "0" and a[i] == "0" and b[i] == "0": b[i - 1] = "X" a[i] = "X" b[i] = "X" counter += 1 elif b[i - 1] == "0" and a[i - 1] == "0" and b[i] == "0": b[i - 1] = "X" a[i - 1] = "X" b[i] = "X" counter += 1 print(counter)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = [["X"] + list(map(str, input())) + ["X"], ["X"] + list(map(str, input())) + ["X"]] n = len(a[0]) ans = 0 for i in range(1, n - 1): if a[0][i] == a[1][i] == "0": if a[0][i - 1] == "0": a[0][i - 1] = "X" a[0][i] = "X" a[1][i] = "X" ans += 1 elif a[1][i - 1] == "0": a[1][i - 1] = "X" a[0][i] = "X" a[1][i] = "X" ans += 1 elif a[0][i + 1] == "0": a[0][i + 1] = "X" a[0][i] = "X" a[1][i] = "X" ans += 1 elif a[1][i + 1] == "0": a[1][i + 1] = "X" a[0][i] = "X" a[1][i] = "X" ans += 1 print(ans)
ASSIGN VAR LIST BIN_OP BIN_OP LIST STRING FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR LIST STRING BIN_OP BIN_OP LIST STRING FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR LIST STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
S1 = input() S2 = input() L = len(S1) memo = {} def dfs(i, p1, p2): if i == L: return 0 key = i, p1, p2 if key in memo: return memo[key] r = 0 if S1[i] == S2[i] == "0": if p1 > 0 or p2 > 0: if p1 > 0 < p2: r = max(dfs(i + 1, 1, 0), dfs(i + 1, 0, 1)) + 1 else: r = dfs(i + 1, 0, 0) + 1 else: r = dfs(i + 1, 1, 1) elif S1[i] == "0": if p1 > 0 and p2 > 0: r = dfs(i + 1, 0, 0) + 1 else: r = dfs(i + 1, 1, 0) elif S2[i] == "0": if p1 > 0 and p2 > 0: r = dfs(i + 1, 0, 0) + 1 else: r = dfs(i + 1, 0, 1) else: r = dfs(i + 1, 0, 0) memo[key] = r return r print(dfs(0, 0, 0))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR IF VAR VAR RETURN VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR VAR STRING IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR RETURN VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER NUMBER
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
import sys input = sys.stdin.readline MOD = 1000000007 MOD2 = 998244353 ii = lambda: int(input().strip("\n")) si = lambda: input().strip("\n") dgl = lambda: list(map(int, input().strip("\n"))) f = lambda: map(int, input().strip("\n").split()) il = lambda: list(map(int, input().strip("\n").split())) ls = lambda: list(input().strip("\n")) let = "abcdefghijklmnopqrstuvwxyz" for _ in range(1): l = [ls() for i in range(2)] n = len(l[0]) ans = 0 for i in range(1, n): if l[0][i - 1] == "0" and l[1][i - 1] == "0": if l[0][i] == "0": ans += 1 l[0][i] = "X" elif l[1][i] == "0": ans += 1 l[1][i] = "X" elif l[0][i] == "0" and l[1][i] == "0": if l[0][i - 1] == "0" or l[1][i - 1] == "0": ans += 1 l[0][i], l[1][i] = "X", "X" print(ans)
IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR STRING IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER VAR STRING STRING EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
c = l = 0 for x in zip(input(), input()): r = x.count("0") l, c = ((r, c), (r == l, c + 1))[l + r > 2] print(c)
ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s = [None, None] s1 = input() s2 = input() s[0] = s1 s[1] = s2 ans = 0 for i in range(len(s1)): if s[0][i] == "0" and s[1][i] == "0": if i + 1 != len(s1): if s[0][i + 1] == "0": s[0] = s[0][0:i] + "//" + s[0][i + 2 :] s[1] = s[1][0:i] + "/" + s[1][i + 1 :] ans += 1 elif s[1][i + 1] == "0": s[1] = s[1][0:i] + "//" + s[1][i + 2 :] s[0] = s[0][0:i] + "/" + s[0][i + 1 :] ans += 1 elif s[0][i] == "0": if i + 1 != len(s1): if s[0][i + 1] == "0" and s[1][i + 1] == "0": s[0] = s[0][0:i] + "//" + s[0][i + 2 :] s[1] = s[1][0 : i + 1] + "/" + s[1][i + 2 :] ans += 1 elif s[1][i] == "0": if i + 1 != len(s1): if s[0][i + 1] == "0" and s[1][i + 1] == "0": s[1] = s[1][0:i] + "//" + s[1][i + 2 :] s[0] = s[0][0 : i + 1] + "/" + s[0][i + 2 :] ans += 1 print(ans)
ASSIGN VAR LIST NONE NONE ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR STRING IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR STRING IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
s1, s2 = input(), input() s1 += "X" * max(0, 3 - len(s1)) s2 += "X" * max(0, 3 - len(s2)) l, count = len(s1), 0 s1, s2 = list(s1), list(s2) for i in range(l - 1): a, b, c, d = s1[i], s1[i + 1], s2[i], s2[i + 1] ss = sum(1 for x in [a, b, c, d] if x == "X") if ss > 1: continue elif ss == 1: count += 1 s1[i], s1[i + 1], s2[i], s2[i + 1] = ["X"] * 4 else: count += 1 s1[i], s1[i + 1], s2[i] = ["X"] * 3 print(count)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP STRING FUNC_CALL VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR VAR BIN_OP STRING FUNC_CALL VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR LIST VAR VAR VAR VAR VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER BIN_OP LIST STRING NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP LIST STRING NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a = input() b = input() n = len(a) ans = 0 l = 2 i = 0 if a[0] == "X": l -= 1 if b[0] == "X": l -= 1 while i < n - 1: count = 0 if a[i + 1] == "0": count += 1 if b[i + 1] == "0": count += 1 if l + count >= 3: ans += 1 if l + count == 3: l = 0 else: l = 1 else: l = count i += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER IF VAR NUMBER STRING VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
l, r = 0, 0 for x in map(lambda x: x.count("0"), zip(input(), input())): l, r = [[x, r], [x == l, r + 1]][l + x > 2] print(r)
ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST VAR VAR LIST VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
m = list(input()) n = list(input()) cnt = 0 for i in range(len(m) - 1): if "000" == m[i] + n[i] + n[i + 1]: m[i] = n[i] = n[i + 1] = "x" cnt = cnt + 1 elif "000" == m[i] + m[i + 1] + n[i + 1]: m[i] = m[i + 1] = n[i + 1] = "x" cnt = cnt + 1 elif "000" == m[i] + m[i + 1] + n[i]: m[i] = m[i + 1] = n[i] = "x" cnt = cnt + 1 elif "000" == m[i + 1] + n[i + 1] + n[i]: m[i + 1] = n[i + 1] = n[i] = "x" cnt = cnt + 1 print(cnt)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF STRING BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF STRING BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF STRING BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF STRING BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board with $2\times n$ squares onto which he wants to put some bishwocks. To his dismay, several squares on this board are already occupied by pawns and Vasya can't put bishwocks there. However, pawns also don't attack bishwocks and they can occupy adjacent squares peacefully. Knowing the positions of pawns on the board, help Vasya to determine the maximum amount of bishwocks he can put onto the board so that they wouldn't occupy the same squares and wouldn't occupy squares with pawns. -----Input----- The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. -----Output----- Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. -----Examples----- Input 00 00 Output 1 Input 00X00X0XXX0 0XXX0X00X00 Output 4 Input 0X0X0 0X0X0 Output 0 Input 0XXX0 00000 Output 2
a, b = list(input()), list(input()) n = len(a) for i in range(n): if a[i] == "0": a[i] = 0 else: a[i] = 1 if b[i] == "0": b[i] = 0 else: b[i] = 1 s = [a, b] ans, prev = 0, 0 for i in range(n - 1): tmp = s[0][i] + s[0][i + 1] + s[1][i] + s[1][i + 1] + prev if tmp == 1: ans += 1 s[0][i], s[1][i], s[0][i + 1], s[1][i + 1] = (1,) * 4 prev = 0 elif tmp == 0: ans += 1 s[0][i], s[1][i] = 1, 1 prev = 1 else: prev = 0 print(ans)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR