description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) for i2 in range(t): n, a, b = map(int, input().split()) s = str(input()) dp = [([0] * 2) for i in range(n)] maxn = 123456789876543212345678 for i in range(n): if i == 0: dp[0][0], dp[0][1] = a + b, maxn elif s[i] == "0": dp[i][0] = min(dp[i - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR NUMBER NU...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) prn = lambda x: print(*x, sep="\n") def solve(): n, a, b = nm() s = list(ma...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR A...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) for i in range(t): n, a, b = map(int, input().split()) s = input() arr = [] c = "0" k = 0 for i in range(n): if s[i] == c: k += 1 else: arr.append(k) k = 1 c = s[i] if len(arr) == 0: print(n * a + b * n ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR IF FU...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) for _ in range(t): n, a, b = map(int, input().split()) l = list(input()) dp1 = [10**18] * (n + 1) dp2 = [10**18] * (n + 1) dp1[0] = b i = 1 while i < n: if l[i] == "0": if l[i - 1] != "1": dp1[i] = min(dp2[i - 1] + 2 * a, dp1[i - 1] + a) +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR ASSIGN VA...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
import sys def input(): return sys.stdin.readline()[:-1] t = int(input()) ans = [] for _ in range(t): n, a, b = map(int, input().split()) s = input() res = [b, 10**30] for i in range(n): tmp = [] if s[i] == "0": tmp.append(min(res[0] + a + b, res[1] + 2 * a + b)) ...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR VAR STRING EXPR FUN...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
Q = int(input()) for _ in range(Q): n, a, b = list(map(int, input().split())) s = list(map(int, input())) m = a * n m += b * (n + 1) if sum(s) == 0: print(m) continue head = s.index(1) for i in reversed(range(n)): if s[i] == 1: tail = i break ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FU...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) while t != 0: n, a, b = map(int, input().split()) pipe = a pillar = b s = input() dp = [[float("inf") for i in range(n + 2)] for j in range(2)] dp[0][0] = pillar for i in range(n): if s[i] == "1": dp[0][i + 1] = float("inf") dp[1][i + 1] = dp[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR VAR ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) for each1 in range(t): data_list = input().split(" ") n = int(data_list[0]) a = int(data_list[1]) b = int(data_list[2]) ss = input() ans = 0 l = 0 r = 0 ss_len = len(ss) i = 0 while i < ss_len: l = i while i < ss_len and ss[i] == "0": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR V...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
for _ in range(int(input())): n, a, b = map(int, input().split()) s = input() next1 = [float("inf")] * (n + 1) j = float("inf") for i in range(n - 1, -1, -1): next1[i] = j if s[i] == "1": j = i ans = a * n + b * (n + 1) i = 0 flag = 0 while i < n: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR IF VAR VAR STRING...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
T = int(input()) for tt in range(0, T): n, a, b = [int(x) for x in input().split()] s = input() cntZero = 1 zeros = [] ones = [] cntOne = 0 cost = 0 for i in range(1, n): if s[i] == "0": cntZero += 1 if cntOne > 0: ones.append(cntOne) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER IF VAR NUM...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
for TT in range(1, int(input()) + 1): n, a, b = map(int, input().split()) s = input() dp = [0, float("inf")] for i in range(n): if "1" in s[i : i + 2]: dp = [float("inf"), min(dp[0] + a, dp[1]) + b] else: dp = [min(dp[0], dp[1] + a), min(dp[0] + a, dp[1]) + b] ...
FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF STRING VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
T = int(input()) for _ in range(T): n, a, b = map(int, input().split()) s = list(map(int, input())) if 1 not in s: print(a * n + b * (n + 1)) continue min_lower_length = 2 * a / b + 1 start = 0 while s[start] == 0: start += 1 end = n - 1 while s[end] == 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR IF NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
T = int(input()) for i in range(T): n, a, b = [int(i) for i in input().split()] s = [int(c) for c in input().strip("0")] cost = 0 nzero = 0 if len(s) == 0: cost = n * a + (n + 1) * b else: cost = (n - len(s) + 2) * (a + b) for e in s: if e == 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
for k in range(int(input())): n, cpipe, cpillar = map(int, input().split()) s = input() if int(s) == 0: print(n * cpipe + n * cpillar + cpillar) else: ti = 0 for i in range(n): if s[i] == "1": ti = i break l = [] ans = 0...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR L...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
import sys input = sys.stdin.readline T = int(input()) for testcases in range(T): n, a, b = list(map(int, input().split())) S = list(map(int, list(input().strip()))) S.append(0) ANS = (n + 1) * b + n * a DP = [[1 << 50, 1 << 50] for i in range(n + 1)] DP[0][0] = 0 for i in range(1, n + 1): ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
import sys def main(): import sys input = sys.stdin.readline for _ in range(int(input())): N, a, b = map(int, input().split()) S = input().rstrip("\n") dp = [([0] * 2) for _ in range(N + 1)] inf = int(float(10**20)) dp[0][0] = b dp[0][1] = inf for i...
IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER NUM...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) for _ in range(t): n, a, b = (int(x) for x in input().split()) s = input() cost = n * (a + b) + b count = 0 i = s.find("1") while 0 <= i < n: j = i while j < n - 1 and s[j + 1] == "1": j += 1 ones = j - i + 1 cost += (ones + 1) * b ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING WHILE NUMBER VAR VAR ASSIGN VAR VAR WHILE VAR BIN_OP VAR NUMBER VAR...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
import sys maxx = 100000000000000001 q = int(input()) for i in range(q): ch = input() L = [int(i) for i in ch.split()] n = L[0] a = L[1] b = L[2] ch = input() M = [[b, maxx]] + [[maxx, maxx] for i in range(n)] for j in range(1, n + 1): M[j][1] = min(M[j - 1][0] + 2 * b + 2 * a, ...
IMPORT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST LIST VAR VAR LIST VAR VAR VAR FUNC_CALL VAR ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
q = int(input()) for Q in range(q): n, a, b = tuple(map(int, input().split())) s = input() if s == "0" * n: print(n * a + (n + 1) * b) continue cost = n * a + 2 * n * b i = 0 while s[i] == "0": cost -= b i += 1 cost += a while i < n: while i < n an...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VA...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
import sys def main(): import sys input = sys.stdin.readline def solve(): n, a, b = map(int, input().split()) s = input() arr = [0] * (n + 1) for i in range(1, n): if s[i] == "1" or s[i - 1] == "1": arr[i] = 1 cnts = [] cnt = 1 ...
IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
import sys input = sys.stdin.readline T = int(input()) for _ in range(T): n, a, b = map(int, input().split()) l = input().strip() p = 0 cur = 0 ans = 0 if "1" not in l: print(b * (n + 1) + a * n) else: while p < n: if l[p] == "1": ans += b * p + 2...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
from sys import stdin item = lambda: stdin.readline().split() it = lambda: stdin.readline()[:-1] for _ in range(int(stdin.readline())): n, a, b = map(int, item()) s = it() x = s.find("1") if x == -1: print(n * (a + b) + b) continue res = (n + 1) * (a + b) + b for y in range(x + ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) while t: t -= 1 n, a, b = [int(x) for x in input().split()] s = input() l = -1 r = -1 for i in range(len(s)): if s[i] == "1": l = i break if l != -1: for i in range(len(s) - 1, -1, -1): if s[i] == "1": r = i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
R = lambda: map(int, input().split()) for _ in range(int(input())): n, a, b = R() s = input() low, high = [0] * (n + 1), [0] * (n + 1) low[-1] = b high[-1] = 10**15 for i in range(n): if "1" == s[i]: high[i] = high[i - 1] + a + 2 * b low[i] = 10**15 else: ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER BIN_OP NUMBER NUMBER FOR VAR F...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
from sys import stdin def ii(): return int(stdin.readline()) def mi(): return map(int, stdin.readline().split()) def li(): return list(mi()) def si(): return stdin.readline() for _ in range(ii()): n, a, b = mi() s = si() p, x, q = n + 2, 0, 2 * n d = s.find("1") if d > -1: ...
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 FUNC_DEF RETURN FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
def mp(): return map(int, input().split()) def f(i, j): return a[i][j] == a[i + 1][j] == a[i][j + 1] == a[i + 1][j + 1] == 1 q = int(input()) for qq in range(q): n, a, b = mp() s = input() dp_u = [0] * (n + 1) dp_d = [0] * (n + 1) dp_u[0] = 10**20 dp_d[0] = b for i in range(1, n)...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR B...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) for _ in range(t): n, pipeCost, pillarCost = map(int, input().split()) road = input() cost = 0 freq = [] curr = "0" currFreq = 0 for i in road: if i == curr: currFreq += 1 else: freq.append(currFreq) curr = i cu...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) for i in range(t): n, a, b = map(int, input().split()) s = input() p = [] p1 = 0 p2 = 0 for j in range(n): if s[j] == "0": p1 += 1 if p2 != 0: p.append(p2) p2 = 0 else: p2 += 1 if p1 != 0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUM...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
def solve(): N, A, B = [int(i) for i in input().split(" ")] road = input() cost = ( A * N + (N + 1) * B + road.count("1") * B + 2 * road.count("01") * A + road.count("01") * B ) maxWorthGap = int(A / B) zeros = 0 wasOne = False for i in range(N): ...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP FUNC_CALL VAR STRING VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR STRING VAR BIN_OP FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) vsp = [] for i in range(t): n, a, b = map(int, input().split()) s = input() ind_of_1 = [] for i in range(n): if s[i] == "1": ind_of_1.append(i) m = len(ind_of_1) j = -1 count = b h = 1 hs = [] for i in range(n - 1): if s[i] == "0" and ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN V...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
from sys import setcheckinterval, stdin setcheckinterval(1000) def iin(): return int(stdin.readline()) def lin(): return list(map(int, stdin.readline().split())) for _ in range(iin()): nn, p, h = lin() s = list(input()) sa = [] i = 0 while i < nn: ch = 0 val = s[i] ...
EXPR FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSI...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
inf = 10**18 t = int(input()) for q in range(t): n, a, b = map(int, input().split()) path = input() dp = [[inf, inf] for i in range(n + 1)] dp[0][0] = b for i in range(0, n): if path[i] == "0": dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + a + b) dp[i + 1][1] = min(dp[i...
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRI...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
import sys t = int(sys.stdin.readline()) for _ in range(t): n, pip_cost, pillor_cost = map(int, sys.stdin.readline().split()) strr = sys.stdin.readline() arr = [(i + 1) for i in range(n) if strr[i] == "1"] pip_len = n + 2 if arr else n pillor_len = (n + 1) * 2 - (arr[0] - 1) - (n - arr[-1]) if arr ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBE...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
def solve(s, n, a, b): cost = a * n cost += b * (n + 1) dp = [] curr = s[0] count = 0 for i in s: if i == curr: count += 1 else: dp.append((curr, count)) curr = i count = 1 dp.append((curr, count)) for i in range(1, len(dp) ...
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR NUM...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
import sys T = int(sys.stdin.readline()) for t in range(0, T): n, a, b = list(map(int, sys.stdin.readline().strip().split())) s = sys.stdin.readline().strip() i = 0 c = n * a + (n + 1) * b v = 0 for j in range(0, n - 1): if s[j] == "1" or s[j + 1] == "1": c = c + b ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR N...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) for kek in range(t): n, a, b = list(map(int, input().split())) s = list(map(int, input())) h = list() j = 0 ans = 0 while j < len(s) and int(s[j]) != 1: j += 1 if j == len(s): ans = n * a + b * (n + 1) else: i = j for j in range(len(s) - 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR N...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
import sys input = lambda: sys.stdin.readline().rstrip("\r\n") for _ in range(int(input())): n, a, b = [int(x) for x in input().split()] s = input() ans = 0 if "1" not in s: print(n * (b + a) + b) continue i = 0 while s[i] == "0": i += 1 ans += a + b ans += a...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR STRING VAR ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
T = int(input()) for i in range(T): n, a, b = map(int, input().split()) s = input() dp = [[(1000000000000000001) for i in range(2)] for j in range(n + 1)] dp[0][0] = a + 2 * b dp[0][1] = 2 * a + 3 * b for i in range(n - 1): if s[i] == "0": if s[i + 1] == "1": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER NUMBER BIN_OP BIN_...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
def main(): def solve(): n, a, b = map(int, input().split()) ss = input() cost = 0 for i in range(n): if ss[i] == "1": last = i cost += a * (i + 1) + b * i break else: print(a * n + b * (n + 1)) ...
FUNC_DEF FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER RETURN FOR VAR...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
for _ in range(int(input())): n, a, b = map(int, input().split()) s = input() s = [i for i in range(n) if s[i] == "1"] if not s: print(n * a + (n + 1) * b) continue ans = (s[0] + n - s[-1] + 2) * (a + b) + b for i in range(len(s) - 1): ans += a + 2 * b if s[i + 1]...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR STRING IF VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBE...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) for _ in range(t): n, a, b = (int(i) for i in input().split()) s = input() price = n * (a + b) + b i = 0 upped = False while i < n: cur = s[i] if cur == "1": j = i + 1 for j in range(i + 1, n): if s[j] != "1": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER FOR V...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) for _ in range(t): n, a, b = map(int, input().split()) s = input() + "1" ans = n * a + (n + 1) * 2 * b cnt_0 = 0 for i in range(len(s)): tmp = 0 if s[i] == "0": cnt_0 += 1 if s[i] == "1" and cnt_0 > 0: if i - cnt_0 == 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
for _ in range(int(input())): n, a, b = map(int, input().split()) c = list(map(int, list(input()))) r = [] l = 1 for i in range(1, n): if c[i] == c[i - 1]: l += 1 else: r.append([l, c[i - 1]]) l = 1 r.append([l, c[-1]]) l = 0 ans = n * ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
for rpt in range(int(input())): roadlength, pipecost, pillarcost = [int(x) for x in input().split(" ")] crossroads = input() res = (roadlength + 1) * pillarcost segments = [] current = "0" currentlength = 1 for i in range(1, roadlength): if crossroads[i] == current: curre...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
rw = int(input()) for wewq in range(rw): n, a, b = map(int, input().split()) s = input() dp = [0] * (n + 1) dp[0] = b t2 = False i = 0 c = [] while i < n - 1: c.append(1) i += 1 while s[i] == s[i - 1] and i < n - 1: c[-1] += 1 i += 1 if...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
inf = 1000000000000000000 t = int(input()) while t > 0: t -= 1 n, pip_price, pil_price = map(int, input().split()) ls = list(input()) dp = [[0, 0] for i in range(n + 5)] dp[0][1] = inf dp[0][0] = pip_price + pil_price for i in range(1, len(ls)): if ls[i] == "1": dp[i][0] ...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR ASSIGN VAR NUMBER NUMBER BIN_OP VAR VAR ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) for i in range(t): n, a, b = [int(x) for x in input().split()] s = [int(x) for x in list(input())] gas = n h = n + 1 index = -1 one = -1 for i in range(n): if s[i] == 0: if index != -1: h += i - index + 1 gas += 2 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF VA...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
Q = int(input()) Qs = [] for _ in range(Q): n, a, b = map(int, input().split()) s = input() Qs.append([n, a, b, s]) for n, a, b, S in Qs: l = 0 L = [] for s in list(S): if s == "0": l += 1 else: if not L: L.append(l) elif l >= 2...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR FOR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR STRING VAR NUMBER IF V...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
for _ in range(int(input())): n, a, b = map(int, input().split()) s = input() suf = [-1] * n t = n for i in range(n - 1, -1, -1): suf[i] = t if s[i] == "1": t = i i, f = 0, 0 ans = a * n + b * (n + 1) while i < n: if s[i] == "1": if f == 0:...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR IF VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR NUMBER NUMBER ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
for t in range(int(input())): n, a, b = list(map(int, input().split())) s = [c for c in input()] bridge = 0 raised = False for i, c in enumerate(s): if c == "1" and not raised: raised = True elif c == "0" and raised: bridge += 1 elif c == "1" and raise...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING VAR ASSIGN VAR NUMBER IF VAR STRING VAR VAR NUMBER IF VAR STRING VAR IF BIN_OP BIN...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
t = int(input()) for _ in range(t): n, a, b = map(int, input().split()) s = list(map(int, list(input()))) g = list() cur = 0 count = 0 for x in s: if x == cur: count += 1 else: g.append(count) count = 1 cur = x ones = sum(s) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIG...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
T = int(input()) for _ in range(T): n, a, b = map(int, input().split()) s = input() res = 0 i = 0 while i < n and s[i] == "0": res += a + b i += 1 if i < n: res += 2 * a while s[n - 1] == "0": res += a + b n -= 1 res += (n - i + 1) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR VAR BIN_OP NUMBER VAR WHILE VAR BIN_OP VAR NUMBER STRING VAR BI...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
T = int(input()) for _ in range(T): nab = list(map(int, input().split())) n, a, b = nab[0], nab[1], nab[2] s = str(input()) crp = list() for i in range(n): if s[i] == "1": crp.append(i) min_cost = (n + 1) * b + n * a if len(crp) == 0: print(min_cost) elif len(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIG...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
T = int(input()) for i in range(0, T): ln = [int(j) for j in input().split(" ")] n = ln[0] a = ln[1] b = ln[2] st = list(input()) ct = 0 zct = 0 pls = 0 pip = 0 seg = [] ft = False for j in range(0, len(st)): if st[j] == "1": ft = False if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
s = lambda: list(map(int, input().split())) T = int(input()) for tc in range(T): n, a, b = s() string = list(map(lambda x: x == "1", input())) cost = a * n + b * (n + 1) isBeginning = True zeros = 0 for x in string: if x: if zeros == 0: cost += b e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR STRING FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
q = int(input().strip()) for i in range(q): n, a, b = [int(x) for x in input().strip().split()] r = [int(x) for x in input().strip()] i = 0 r2 = [] while i < n: if r[i] == 0: r2.append([0, 0]) while i < n and r[i] == 0: r2[-1][1] += 1 i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER WHILE VAR...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
T = int(input()) for t in range(T): n, a, b = map(int, input().split()) A = list(map(int, list("0" + input() + "0"))) DP = [[(10**18) for i in range(2)] for j in range(n + 1)] DP[0][0] = b for i in range(1, n + 1): if A[i + 1] == 0 and A[i] == 0: DP[i][0] = min(DP[i - 1][0] + a +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP BIN_OP STRING FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER AS...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
n = int(input()) for i in range(n): raw = input().split() n, a, b = [int(x) for x in raw] s = input() x = n y = n + 1 count = 0 check_1 = [] check_0 = [] count_0 = 0 status = [] for i in range(n - 1): if s[i] == "1" and s[i + 1] == "1": count += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR ...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
for _ in range(int(input())): n, a, b = map(int, input().split()) s = input() if "1" not in s: print((n + 1) * b + a * n) else: cg = 0 for i in range(len(s) - 1): if s[i] == "1" and s[i - 1] == "0": cg += 1 if s[i] == "1": c...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP...
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string...
for _ in range(int(input())): n, a, b = list(map(int, input().split())) s = input() if s == "0" * n: print(a * n + b * n + b) continue ans = 0 ind = 0 ind2 = n - 1 pref = 0 suf = 0 while ind2 >= 0 and s[ind2] == "0": ind2 -= 1 suf += 1 while ind < ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NU...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
for _ in range(int(input())): l1 = input() l2 = input() if l1[0] == "#": if l2[0] == "#": print("No") continue else: start = 2 elif l2[0] == "#": start = 1 else: start = 0 switch = 0 i = f = 0 while i < len(l1): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER STRING IF VAR NUMBER STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VA...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
for _ in range(int(input())): l1, l2, simp = input(), input(), 0 for i in range(len(l1)): if l1[i] == "#" and l2[i] == "#": print("No") simp = 1 break if simp == 0: cnt, cake = 0, 0 for i in range(len(l2)): if cake == 0: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
for t in range(int(input())): s = [] s.append(input()) s.append(input()) n = len(s[0]) flag = [0, 0] count = [0, 0] lane = 0 i = 0 switch = 0 if s[0][0] == "#": flag[0] = 1 else: while i < n - 1: x = (lane + 1) % 2 if s[lane][i + 1] == ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER STRING ASSIGN VAR...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
t = int(input()) while t: l1 = input() l2 = input() n = len(l1) def minGravity(s1, s2): n = len(s1) arr = [0] * 2 arr[0] = s1 arr[1] = s2 s1Dirty = n s2Dirty = n for i in range(n): if s1[i] == "#": s1Dirty = i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
ma = 10**6 for _ in range(int(input())): s1 = input() s2 = input() l1 = [ma for i in range(len(s1))] l2 = [ma for i in range(len(s2))] if s1[0] == ".": l1[0] = 0 if s2[0] == ".": l2[0] = 0 for i in range(len(s1)): if l1[i] < ma and s1[i] == ".": if s2[i] =...
ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING ASSIGN VAR NUMBER NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER N...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
def solve(one, two): dis = 0 switch = 0 on = one notOn = two possible = True while dis <= N - 1 and possible: if on[dis] == ".": dis += 1 elif notOn[dis] == ".": dis += 1 switch += 1 on, notOn = notOn, on else: p...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL ...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
t = int(input()) for _ in range(t): l1 = list(input()) l2 = list(input()) flag = 0 for i in range(len(l1)): if l1[i] == l2[i] == "#": flag = 1 break if flag == 1: print("No") else: print("Yes") dp1 = [0] * (len(l1) + 1) dp1[0] = 0 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VA...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
for h in range(int(input())): L1 = input() L2 = input() L1obs = [(0) for i in range(len(L1))] L2obs = [(0) for i in range(len(L2))] L1counter = 0 L2counter = 0 valid = 1 for i in range(1, len(L1) + 1): if L1[-i] == "." and L2[-i] == ".": L1counter += 1 L2c...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMB...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
t = int(input()) while t: t = t - 1 a = input() b = input() c = 0 f = 0 s = 0 for i in range(len(a)): if a[i] == "#" and c != "b": if c == 0: c = "b" elif b[i] == "#": f = 1 break else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR STRING IF VAR NUMBER ASSIGN VAR STRING IF VAR VAR STRING ASSIGN VAR NUMBER A...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
T = int(input()) for i in range(T): s = input() s2 = input() yo = True for i in range(len(s)): if s[i] == s2[i] == "#": yo = False if yo == False: print("No") else: swaps = 0 first = -1 second = -1 for i in range(len(s)): if...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR F...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
for _ in range(int(input())): a = input() b = input() l = len(a) x = a.find("#") y = b.find("#") if x == -1 or y == -1: print("Yes") print("0") continue if a[-1] == "#" and b[-1] == "#" or a[0] == "#" and b[0] == "#": print("No") continue if x == y...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER ...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
t = int(input()) for _ in range(t): st = [input(), input()] n = len(st[0]) exec = True for i in range(n): if st[0][i] == st[1][i] == "#": print("No") exec = False break if exec: print("Yes") dp = [[(0) for _ in range(n + 1)] for _ in range(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUM...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
import sys for _ in range(int(input())): a1 = list(input()) a2 = list(input()) count = 0 DP1 = [0] * len(a1) DP2 = [0] * len(a1) n = len(a1) for i in range(n): if a1[i] == "#" and a2[i] == "#": print("No") count = 1 break if count != 1: ...
IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRIN...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
import sys def calculate(m, x): resp = 0 if m[x][0] == "#": return len(m[x]) + 1 for i in range(0, len(m[0]) - 1): if m[x][i + 1] == "#": if m[(x + 1) % 2][i + 1] == "#": return len(m[x]) + 1 else: x = (x + 1) % 2 resp...
IMPORT FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR NUMBER STRING RETURN BIN_OP FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER STRING RETURN BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN ...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
for t in range(int(input())): s1 = input() s2 = input() n = len(s1) f = 0 for i in range(n): if s1[i] == s2[i] == "#": f = 1 if f == 1: print("No") continue c = 0 flag = -1 for i in range(0, n): if s1[i] == "#": if flag == 0: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
import sys def perform(): lane_1 = list(input()) lane_2 = list(input()) lane_len = len(lane_1) pos = False min_switch = sys.maxsize lanes = [lane_1, lane_2] if lane_1[0] != "#": t_pos = True t_switch = 0 cur_lane = 0 for i in range(lane_len): if ...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST VAR VAR IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR STRING ASSIGN VAR NUMBER...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
t = int(input()) while t > 0: a = input() b = input() l = len(a) flag = 1 for i in range(l): if a[i] == "#" and b[i] == "#": flag = 0 break if flag == 1: if a[0] == ".": count1 = 0 start = "a" i = 0 while i <...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER W...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
t = int(input()) for i in range(t): s1 = input() s2 = input() gr = 0 flag = 99999999999999999 cur = 0 for i in range(len(s1)): if s1[i] == s2[i] == "#": gr = flag break elif s1[i] == "#": if cur == 1: gr += 1 cur = 2...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR STRING ASSIGN VAR VAR IF VAR VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VA...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
import sys sys.setrecursionlimit(2000000) def dp_jump(lane_num, ind, lane, cache, n): if ind == n - 1 and lane[lane_num][ind] != "#": cache[lane_num][ind] = 0 return cache[lane_num][ind] elif ind >= n: return float("inf") elif cache[lane_num][ind] != None: return cache[lan...
IMPORT EXPR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR BIN_OP VAR NUMBER VAR VAR VAR STRING ASSIGN VAR VAR VAR NUMBER RETURN VAR VAR VAR IF VAR VAR RETURN FUNC_CALL VAR STRING IF VAR VAR VAR NONE RETURN VAR VAR VAR IF VAR VAR VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR STRING RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR B...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
for _ in range(int(input())): s = str(input()) p = str(input()) pos = "" ans = 0 imp = 0 start = 0 for i in range(len(s)): if start == 0: if s[i] == "#" and p[i] != "#": pos = "p" start = 1 elif p[i] == "#" and s[i] != "#": ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR STRING VAR VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMB...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
T = int(input()) for z in range(T): path1 = list(input()) path2 = list(input()) distances1 = [(999999) for i in range(len(path1))] distances2 = [(999999) for i in range(len(path1))] if path1[0] == "#" and path2[0] == "#": print("No") continue if path1[0] == ".": distances...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING IF V...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
def sfidx(ls, a): try: return ls.index("#") except: return len(ls) for _ in range(int(input())): L1 = list(input().strip()) L2 = list(input().strip()) cmp = [L1, L2] lin = 0 if sfidx(L1, "#") > sfidx(L2, "#") else 1 sw = 0 block = False for a in range(len(L1)): ...
FUNC_DEF RETURN FUNC_CALL VAR STRING RETURN FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR STRING NUMBER NUMBER ASSIGN VAR ...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
INF = 1 << 30 for _ in range(int(input())): l1 = input() l2 = input() d1 = d2 = 0 for i, j in zip(l1, l2): d1, d2 = INF if i == "#" else min(d1, d2 + 1), ( INF if j == "#" else min(d2, d1 + 1) ) ans = min(d1, d2) if ans >= INF: print("No") else: pr...
ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR STRING VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR STRING VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
def ret_val(s1, s2): n = len(s1) change = 0 lane = 0 if "#" not in s1: return change if "#" not in s2: return change x1 = s1.index("#") x2 = s2.index("#") if x1 > x2: lane = 1 elif x1 < x2: lane = 2 else: return -1 for i in range(1, n):...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR RETURN VAR IF STRING VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR VAR VAR ...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
for _ in range(int(input())): a = input() b = input() n = len(a) i = -1 flag = True currentlane = 0 jumps = 0 if "#" in a and "#" in b: if a.index("#") > b.index("#"): currentlane = 0 else: currentlane = 1 while i < n - 1: if a[...
FOR VAR FUNC_CALL VAR FUNC_CALL 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR STRING VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
test = int(input()) l1 = [] l2 = [] for j in range(0, test): l1 = input() l2 = input() x = 1 y = 0 c = 0 for i in range(0, len(l1)): if l1[i] == "." and l2[i] == "#": if x == 2: x = 1 y = y + 1 elif l2[i] == "." and l1[i] == "#": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING IF VAR NUMBER ASSIGN VAR NUMBER ...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
for t in range(int(input())): l1 = list(input().strip()) l2 = list(input().strip()) n = len(l1) l = [[l1[i], l2[i]] for i in range(n)] flag = True if l1[0] == "#" and l2[0] == "#" or l1[-1] == "#" and l2[-1] == "#": print("No") continue ptr = 1 if l[0][1] == "." else 0 ct...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER STR...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
def test(l1, l2): for i in range(len(l1)): if l1[i] == l2[i] == "#": return "No" return "Yes" def farest(l): i = 0 while i < len(l) and l[i] == ".": i += 1 return i - 1 def minop(l1, l2): c = 0 if l2[0] == ".": if l1[0] == "#": l1, l2 = l2,...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR STRING RETURN STRING RETURN STRING FUNC_DEF ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER STRING IF VAR NUMBER STRING ASSIGN VAR VAR VAR VAR IF FUNC_CALL VAR VA...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
def func(cur, other): i = 0 cnt = 0 n = len(cur) while i < n - 1: if cur[i + 1] == ".": i += 1 elif other[i + 1] == "#": return "No" break else: i += 1 cur, other = other, cur cnt += 1 return cnt t = in...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING RETURN STRING VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN V...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
def solve(): num_test = int(input()) for i in range(num_test): test_case() def test_case(): lane1 = input() lane2 = input() destination = find_destination(lane1, lane2) if len(destination) == 1: print("No") else: print("Yes") print(destination[1]) def find...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBE...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
for __ in range(int(input())): a1 = input() a2 = input() dp1 = [0] * len(a1) dp2 = [0] * len(a1) count = 0 j = 0 while j < len(a1): if a1[j] == "#" and a2[j] == "#": count = 1 print("No") break j += 1 if count != 1: if a1[0] == ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER EXPR FUNC...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
def test(l1, l2): for i in range(len(l1)): if l1[i] == l2[i] == "#": return "No" return "Yes" def farest(l): i = 0 while i < len(l) and l[i] == ".": i += 1 return i - 1 def switch(x): return "l1" if x == "l2" else "l2" def affect(x, l1, l2): return l1 if x =...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR STRING RETURN STRING RETURN STRING FUNC_DEF ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF RETURN VAR STRING STRING STRING FUNC_DEF RETURN VAR STRING VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN V...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
t = int(input()) for _ in range(t): l1 = list(input()) l2 = list(input()) l = [l1, l2] n = len(l1) ans = [([10**6] * n) for i in range(2)] if l1[0] == ".": ans[0][0] = 0 if l2[0] == ".": ans[1][0] = 0 if l1[0] == "#" and l2[0] == "#": print("No") continue ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER VAR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER NUMBER NUMBE...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
T = int(input()) for _ in range(0, T): L1 = input() L2 = input() temp = 0 for i in range(0, len(L1)): if L1[i] == "#" and L2[i] == "#": temp = 1 break if temp != 0: print("No") else: ans1 = 4 * len(L1) + 100 ans2 = 4 * len(L1) + 100 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL ...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
def solve(lanes): lanelength = len(lanes[0]) dp = [[False] * lanelength, [False] * lanelength] for pos in range(lanelength): for lane in (0, 1): if not pos: dp[lane][pos] = lanes[lane][pos] == "." continue else: dp[lane][pos] = ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR FOR VAR NUMBER NUMBER IF VAR ASSIGN VAR VAR VAR VAR VAR VAR STRING ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR STRING FUNC_CALL VAR LIST VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBE...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
for t in range(int(input())): a = input() b = input() n = len(a) if a[0] == "#" and b[0] == "#": print("No") continue f1 = 1 c1 = 0 j = 1 if a[0] == ".": for i in range(1, n): if a[i] == "#" and b[i] == "#": f1 = 0 break...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
n = int(input()) for _ in range(n): a = list(input()) b = list(input()) flag = False tr = 0 for i, j in zip(a, b): if tr == 0: if i == "#": tr = 2 if j == "#": tr = 1 if i == "#" and j == "#": print("No") ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER IF VAR STRING VAR STRING EXPR...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
t = int(input()) for i in range(t): l1 = input() l2 = input() n = len(l1) dp1 = [] dp2 = [] for y in range(n): dp1.append(0) dp2.append(0) c = 0 for k in range(0, n): if l1[k] == "#" and l2[k] == "#": c = 1 break if c == 0: if l...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRI...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
import sys for t in range(int(input())): l1 = input() l2 = input() dp1 = [] dp2 = [] lengt = len(l1) for i in range(lengt): dp1.append(0) dp2.append(0) c = 0 for i in range(len(l1)): if l1[i] == "#" and l2[i] == "#": c = 1 print("No") ...
IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRIN...
Read problems statements in Mandarin Chinese and Russian. Chef likes to play games a lot. Gravity Guy is one such interesting game. "Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w...
UPPER = 0 LOWER = 1 def main(): T = int(input()) for i in range(T): lanes = input(), input() upper_obstacle = lanes[UPPER].find("#") if upper_obstacle == -1: print("Yes") print(0) continue lower_obstacle = lanes[LOWER].find("#") if lo...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR ...