description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
It took Neko an entire day to turn back to normal. Neko reported to Aki that he saw a lot of w... | N = int(input())
mod = 10**9 + 7
dp = [([0] * (N + 1)) for _ in range(N + 1)]
dp[1][0] = 1
dp[1][1] = 1
for i in range(2, N + 1):
if i % 2:
dp[i][i] = 1 + i // 2
else:
dp[i][i] = i // 2
for j in range(i - 1, -1, -1):
dp[i][j] = (dp[i][j + 1] + dp[i - 1][j - 1] + j % 2) % mod
print(dp... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ... |
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
It took Neko an entire day to turn back to normal. Neko reported to Aki that he saw a lot of w... | N = int(input())
MOD = 10**9 + 7
dp = [([0] * (2020 + 1)) for _ in range(2020 + 1)]
dp[1][1] = 1
ans = 0
for i in range(2, N + 2):
for j in range(1, i + 1):
dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD
if (i + j) % 2 == 1:
ans = (ans + dp[i][j]) % MOD
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER A... |
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
It took Neko an entire day to turn back to normal. Neko reported to Aki that he saw a lot of w... | n = int(input())
mod = 10**9 + 7
dp = [([0] * (n + 1)) for i in range(2 * n + 1)]
dp[0][0] = 1
for d in range(1, 2 * n + 1):
for v in range(n + 1):
if v + 1 <= n:
dp[d][v + 1] += dp[d - 1][v]
dp[d][v + 1] %= mod
if v - 1 >= 0:
dp[d][v - 1] += dp[d - 1][v]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF B... |
Read problem statements in [Bengali], [Russian], [Mandarin] and [Vietnamese] as well.
The *functional array* of an array A = [A_{1}, A_{2}, \dots, A_{N}] is the array fA of size N-1, where fA_{i} = A_{i+1} - A_{i} for 1≤ i < N. For example, if A = [2, 3, 9, 11] then fA = [1, 6, 2].
You are given two arrays B = [B_{1}... | from sys import stdin
input = stdin.readline
def answer():
if n == 1:
return "YES"
for i in range(n - 1):
if b[i] > b[i + 1]:
return "NO"
req, dp = 0, 0
for i in range(m):
diff = b[req + 1] - b[req]
dp |= dp << z[i] & (1 << 100001) - 1
dp |= 1 << z[... | ASSIGN VAR VAR FUNC_DEF IF VAR NUMBER RETURN STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER RETURN STRING ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER VAR BIN_OP BI... |
Read problem statements in [Bengali], [Russian], [Mandarin] and [Vietnamese] as well.
The *functional array* of an array A = [A_{1}, A_{2}, \dots, A_{N}] is the array fA of size N-1, where fA_{i} = A_{i+1} - A_{i} for 1≤ i < N. For example, if A = [2, 3, 9, 11] then fA = [1, 6, 2].
You are given two arrays B = [B_{1}... | for _ in range(int(input())):
N, M = map(int, input().strip().split(" "))
B = list(map(int, input().strip().split(" ")))
Z = list(map(int, input().strip().split(" ")))
yes = M >= N - 1
for i in range(1, N):
yes = yes and B[i] >= B[i - 1]
ind = 0
for i in range(N - 1):
if not ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR 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 VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NU... |
Parsa has a humongous tree on $n$ vertices.
On each vertex $v$ he has written two integers $l_v$ and $r_v$.
To make Parsa's tree look even more majestic, Nima wants to assign a number $a_v$ ($l_v \le a_v \le r_v$) to each vertex $v$ such that the beauty of Parsa's tree is maximized.
Nima's sense of the beauty is rat... | import sys
input = sys.stdin.readline
def dfs(i, p, l0, l1, dp0, dp1, adj):
for j in adj[i]:
if j != p:
dfs(j, i, l0, l1, dp0, dp1, adj)
dp0[p] += max(dp0[i] + abs(l0[p] - l0[i]), dp1[i] + abs(l0[p] - l1[i]))
dp1[p] += max(dp0[i] + abs(l1[p] - l0[i]), dp1[i] + abs(l1[p] - l1[i]))
de... | IMPORT ASSIGN VAR VAR FUNC_DEF FOR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ... |
Parsa has a humongous tree on $n$ vertices.
On each vertex $v$ he has written two integers $l_v$ and $r_v$.
To make Parsa's tree look even more majestic, Nima wants to assign a number $a_v$ ($l_v \le a_v \le r_v$) to each vertex $v$ such that the beauty of Parsa's tree is maximized.
Nima's sense of the beauty is rat... | import sys
input = sys.stdin.buffer.readline
for t in range(int(input())):
N = int(input())
X = [list(map(int, input().split())) for i in range(N)]
G = [[] for i in range(N)]
for i in range(N - 1):
a, b = map(int, input().split())
a -= 1
b -= 1
G[a].append(b)
G[b... | IMPORT ASSIGN VAR VAR 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 VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL... |
Parsa has a humongous tree on $n$ vertices.
On each vertex $v$ he has written two integers $l_v$ and $r_v$.
To make Parsa's tree look even more majestic, Nima wants to assign a number $a_v$ ($l_v \le a_v \le r_v$) to each vertex $v$ such that the beauty of Parsa's tree is maximized.
Nima's sense of the beauty is rat... | import sys
input = sys.stdin.readline
def dfs(u, p, dp0, dp1, adj, lB, rB):
for v in adj[u]:
if v != p:
dfs(v, u, dp0, dp1, adj, lB, rB)
dp0[p] += max(dp0[u] + abs(lB[p] - lB[u]), dp1[u] + abs(lB[p] - rB[u]))
dp1[p] += max(dp0[u] + abs(rB[p] - lB[u]), dp1[u] + abs(rB[p] - rB[u]))
de... | IMPORT ASSIGN VAR VAR FUNC_DEF FOR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ... |
Parsa has a humongous tree on $n$ vertices.
On each vertex $v$ he has written two integers $l_v$ and $r_v$.
To make Parsa's tree look even more majestic, Nima wants to assign a number $a_v$ ($l_v \le a_v \le r_v$) to each vertex $v$ such that the beauty of Parsa's tree is maximized.
Nima's sense of the beauty is rat... | import sys
input = sys.stdin.buffer.readline
def main():
t = int(input())
INF = float("inf")
for _ in range(t):
n = int(input())
L = []
R = []
for i in range(n):
l, r = map(int, input().split())
L.append(l)
R.append(r)
G = [[] fo... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL ... |
Parsa has a humongous tree on $n$ vertices.
On each vertex $v$ he has written two integers $l_v$ and $r_v$.
To make Parsa's tree look even more majestic, Nima wants to assign a number $a_v$ ($l_v \le a_v \le r_v$) to each vertex $v$ such that the beauty of Parsa's tree is maximized.
Nima's sense of the beauty is rat... | import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
n = int(input())
a = [0] + [list(map(int, input().split())) for i in range(n)]
adj = [[] for i in range(n + 1)]
for i in range(n - 1):
u, v = map(int, input().split())
adj[u].append(v)
adj[v].append(u)
... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER 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... | for _ in range(int(input())):
n, a, b = list(map(int, input().split()))
s = [int(i) for i in input()]
temp, ar, tot = [0] * 3
tot += a * n
for i in s:
if not i:
if ar:
temp += 1
ar = 0
else:
temp += 1
ar = 1
tot += t... | 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 VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP LIST NUMBER NUMBER VAR BIN_OP VAR VAR FOR VAR VAR IF VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN 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... | q = int(input())
for query in range(q):
n, a, b = map(int, input().split())
s = input()
cost, up = a * n + (n + 1) * b, False
i = 0
while i < n - 1:
if up:
cost += b
elif s[i] == "0" and s[i + 1] == "1" and not up:
cost += a
up = True
if up... | 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 VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR IF VAR VAR STRING VAR BIN_OP VAR 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... | t = int(input())
for it in range(t):
n, a, b = map(int, input().split())
s = input()
dp = [([int(1e18)] * 2) for i in range(n + 1)]
dp[0][0] = b
for i in range(n):
if s[i] == "1":
dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a + 2 * b)
else:
dp[i + 1][0] = min(... | 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 FUNC_CALL VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING 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... | t = int(input())
while t > 0:
t -= 1
n, a, b = map(int, input().split())
s = input()
i = 0
ans = 0
while i < n:
j = i
while j < n:
if s[j] != s[i]:
break
j += 1
if s[i] == "0":
k = j - i
c1 = (k + 2) * a + (k... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR WHILE VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN 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... | m = int(input())
for i in range(m):
t = 0
n, a, b = map(int, input().split())
s = list(input())
for j in range(n):
s[j] = int(s[j])
k = s[0]
p = 1
d = []
for j in range(1, n):
if s[j] == s[j - 1]:
p += 1
else:
d.append(p)
p = 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR 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 FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR 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... | def minCost(n, road, a, b):
start = end = price = 0
price += b
while end != n:
if end < n - 1 and road[end + 1] == 0:
end += 1
else:
length = end - start
if start == 0:
if end == n - 1:
return n * a + n * b + b
... | FUNC_DEF ASSIGN VAR VAR VAR NUMBER VAR VAR WHILE VAR VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER IF VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_O... |
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(input())
input = sys.stdin.readline
maxi = 9999999999999999999999999999999999999999999999999999999
while t > 0:
t -= 1
n, aa, b = map(int, input().split())
a = list(input())
for i in range(n):
a[i] = int(a[i])
dp = [[0, 0] for i in range(n + 1)]
if a[1] == 0:
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL 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 i in range(t):
n, x, y = map(int, input().split())
a = input()
if a == "0" * n:
print((n + 1) * y + n * x)
else:
r1 = 0
r2 = 0
s = 1
b = []
S = 0
k = 0
for i in range(1, n):
if a[i] != a[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 IF VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST 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... | from itertools import groupby
total = int(input())
for i in range(total):
n, a, b = [int(x) for x in input().split()]
road = input()
sroad = ["".join(group) for key, group in groupby(road)]
l = len(sroad)
if l == 1:
print(n * a + (n + 1) * b)
else:
cnt = 0
total_cost = 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 ASSIGN VAR FUNC_CALL STRING VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR 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 = map(int, input().split())
s = input()
res = 0
i = 0
if n == 2:
print(3 * b + 2 * a)
continue
if s == "0" * n:
print((n + 1) * b + n * a)
continue
while i < len(s):
if s[i] == "0":
if s[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 IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR IF VAR BIN_OP STRING VAR EXPR FUNC_CALL 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... | mod = int(1000000000.0) + 7
x = float("inf")
def ip(mode):
if mode == 0:
return int(input())
if mode == 1:
return list(map(int, input().split()))
if mode == 2:
return input()
if mode == 3:
return list(map(str, input().split()))
if mode == 4:
return map(int, ... | ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF IF VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER RETURN FUNC_CALL VAR IF VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL 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... | def mi():
return list(map(int, input().split()))
for _ in range(int(input())):
n, a, b = mi()
s = list(map(int, input()))
ans = (a + b) * n + b
if 1 not in s:
print(ans)
continue
i1 = s.index(1)
i2 = n - 1 - s[::-1].index(1)
ans += 2 * a + (i2 - i1 + 2) * b
i = i1
... | FUNC_DEF RETURN FUNC_CALL 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 FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL 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... | for _ in range(int(input())):
n, pipe_price, pillar_price = map(int, input().split())
s = input()
ans = pillar_price * (n + 1) + pipe_price * n
max_space = int(pipe_price * 2 / pillar_price)
i = 0
while i < n and s[i] == "0":
i += 1
if i == n:
print(ans)
continue
... | 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 BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF 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... | for i in range(int(input())):
n, a, b = input().split(" ")
n = int(n)
a = int(a)
b = int(b)
patterns = list(input())
groups = []
bit = "0"
count = 0
for i in patterns:
if i == bit:
count += 1
else:
groups.append(count)
count = 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER 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... | T = int(input())
for _ in range(T):
n, a, b = map(int, input().split())
s = [int(x) for x in input()]
ans = (n + 1) * b
k = 0
fp = True
for i in range(len(s)):
if s[i] == 0:
k += 1
else:
if fp:
fp = False
ans += (k + 2) * 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 VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER 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... | T = int(input())
for _ in range(T):
n, a, b = [int(i) for i in input().split()]
road = input()
num_one = 0
zero_seg = [(0) for i in range(n)]
num_zer = 0
len_zer = 0
acc_down = True
for i in range(n):
if road[i] == "1":
num_one += 1
if acc_down:
... | 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 NUMBER ASSIGN VAR NUMBER 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 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... | for _ in range(int(input())):
n, a, b = map(int, input().split())
s = input().strip()
ans = (n + 1) * b + n * a
if "1" in s:
ans += 2 * a
s = s[s.find("1") : s.rfind("1") + 1]
t = [0] * (len(s) + 1)
for i in range(len(s)):
x = int(s[i])
t[i] = max(... | 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 ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR VAR IF STRING VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER 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 j in range(t):
n, a, b = map(int, input().split())
s = input()
k = 0
z = 0
for i in range(n):
if s[i] == "0":
z += 1
else:
if z == 1:
if i == z:
k += 3 * b + 2 * a
else:
... | 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 FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR 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... | from itertools import groupby
T = int(input())
for _ in range(T):
n, a, b = tuple(map(int, input().split()))
s = input()
G = [(k, len(list(g)), False) for k, g in groupby(s)]
G[-1] = G[-1][0], G[-1][1], True
q = 0
state = 0
for k, L, last in G:
if state == 0 and k == "0":
... | 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 ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER ASSIGN 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... | t = int(input())
for x in range(t):
n, a, b = map(int, input().split())
l = list(input())
s = 0
i = 0
while i < n:
if i == 0:
while i < n and l[i] != "1":
i += 1
s += a + b
s += a
if i == n:
s -= 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 NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR 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... | T = int(input())
for _ in range(T):
n, a, b = list(map(int, input().split()))
s = input()
ans = n * a + (n + 1) * b
li = s.find("1")
if li >= 0:
ri = s.rfind("1")
ans += a + a + (ri - li + 2) * b
lens = []
for i in range(li + 1, ri):
if s[i] == "0":
... | 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 ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING VAR 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 get_road_chunk(cur_pos):
r = cur_pos
while r + 1 < len(s) and s[r + 1] == "0":
r += 1
return r - cur_pos + 1
T = int(input())
for i in range(T):
n, a, b = map(int, input().split())
s = input()
k = 0
p = b
cur_level = 1
while k < len(s):
if s[k] == "1":
... | FUNC_DEF ASSIGN VAR VAR WHILE BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR 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 NUMBER 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... | inf = 10000000000000000000000000000000000000000000000000000000000000000
def solve(n, a, b, s):
dp = [[]] * 2
for i in range(2):
dp[i] = [0] * n
dp[0][0] = (n + 1) * (a + b) - a
dp[1][0] = inf
for i in range(1, n):
if s[i] == "1":
dp[1][i] = min(dp[1][i - 1] + b, dp[0][i... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR NUMBER 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... | t = int(input())
for i in range(t):
n, a, b = map(int, input().split())
s = input()
arr = [[(10**31) for i in range(2)] for j in range(n + 1)]
arr[0][0] = b
for i in range(1, n + 1):
if s[i - 1] == "0":
arr[i][1] = min(arr[i - 1][1] + 2 * b + a, arr[i - 1][0] + 2 * b + 2 * 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 ASSIGN VAR BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP 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 j in range(t):
n, a, b = map(int, input().split())
s = str(input())
string = [s[i] for i in range(n)]
for i in range(1, n - 1):
if string[i] == "0":
if string[i - 1] == "1" and string[i + 1] == "1":
string[i] = "1"
del s
zero = []
one ... | 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 VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR 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... | q = int(input())
for query in range(q):
n, a, b = map(int, input().split())
s = input()
pod = []
count = 1
for i in range(1, n):
if s[i] != s[i - 1]:
pod.append(count)
count = 1
else:
count += 1
pod.append(count)
wyn = n * a + 2 * n * b + 2... | 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 FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL 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... | x = int(input())
Ans = []
for i in range(x):
n, a, b = map(int, input().split())
s = input()
index_of_ferst = -1
for j in range(len(s)):
if s[j] == "1" and index_of_ferst == -1:
index_of_ferst = j
index_of_end = -1
for j in range(len(s) - 1, -1, -1):
if s[j] == "1" an... | 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 NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP 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... | test = int(input())
for _ in range(test):
n, a, b = map(int, input().split())
s = input()
ans = a * n + b * (n + 1)
for i in range(n):
if s[n - i - 1] == "1":
s = s[: n - i]
break
for i in range(len(s)):
if s[i] == "1":
s = s[i:]
break
... | 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 BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER STRING ASSIGN VAR VAR BIN_OP VAR VAR 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... | def gns():
return list(map(int, input().split()))
t = int(input())
for ti in range(t):
n, a, b = gns()
s = input()
ans = s.split("1")
ans = [len(x) for x in ans if len(x) > 0]
cst = a * n + 2 * a
cst += (n + 1) * 2 * b - ans[0] * b - ans[-1] * b
if len(ans) == 1:
print((n + 1) ... | FUNC_DEF RETURN 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 ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP 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... | def main():
T = int(input())
for _ in range(T):
n, a, b = [int(s) for s in input().split()]
s = [int(x) for x in list(input())]
lengths = []
current = 0
length = 0
for segment in s:
if segment == current:
length += 1
else:
... | FUNC_DEF 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 LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR 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... | C = []
for _ in range(int(input())):
n, a, b = map(int, input().split())
pre = None
pos = [None, None]
genc = False
x = 0
cost = (a + b) * n + b
for i, cur in enumerate(input()):
if pre == None:
pre = "0"
continue
if cur == "0":
if pre == "... | ASSIGN VAR LIST 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 NONE ASSIGN VAR LIST NONE NONE ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NONE ASSIGN 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... | for _ in range(int(input())):
n, a, b = map(int, input().split())
road = input()
lows = []
i = 0
cost = n * (a + b) + b
while i != n and road[i] == "0":
i += 1
if i == n:
print(cost)
continue
cost += a * 2
while i < n:
start = i
while i < n and... | 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 LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER WHILE ... |
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
mod = 1000000007
def get_array():
return list(map(int, sys.stdin.readline().split()))
def get_ints():
return map(int, sys.stdin.readline().split())
def input():
return sys.stdin.readline()
def print_array(a):
print(" ".join(map(str, a)))
def main():
for _ in range(int(input()))... | IMPORT ASSIGN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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
T = int(sys.stdin.readline())
for t in range(T):
n, a, b = list(map(int, sys.stdin.readline().split()))
road = sys.stdin.readline().rstrip()
intersection = road.count("1")
if intersection > 1:
base = a * (n + 2) + (n + 1) * b
plus = 0
begin = road.index("1")
z... | IMPORT 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR ASSIGN 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... | MAXN = float("inf")
T = int(input())
for _ in range(T):
n, a, b = map(int, input().split())
s = list(map(int, input()))
dp = [b, MAXN]
for i in range(n):
if s[i]:
dp[0], dp[1] = MAXN, dp[1] + a + 2 * b
else:
dp[0], dp[1] = min(dp[0] + a + b, dp[1] + 2 * a + b), mi... | ASSIGN VAR FUNC_CALL VAR STRING 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 ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR NUMBER VAR NUMBER VAR 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 minCost2(n, road, a, b):
height = 1
cost = b
s = -1
for i in range(0, n):
cost += a + b
if i < n - 1 and (road[i] == 1 or road[i + 1] == 1):
cost += b
if height == 1:
cost += a
height = 2
if road[i] == 1 and s != -1:... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR 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... | q = int(input())
R = lambda: list(map(int, input().split()))
for j in range(q):
n, a, b = R()
l = input()
l += "0"
n += 1
s = b
t = 0
if a >= b:
p = 1
else:
p = 0
k = 1
test = 0
for i in range(0, n - 1):
if l[i] == "0" and l[i + 1] == "1" and t == 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN 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())
for _ in range(q):
n, a, b = map(int, input().split())
s = str(input())
dp = [0] * (len(s) + 1)
for i in range(len(s) + 1):
dp[i] = [0] * 2
dp[0][0] = b
dp[0][1] = 1000000000000000.0
for i in range(n):
if s[i] == "0":
dp[i + 1][0] = min(dp[i][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 ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP LIST 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... | t = int(input())
for i in range(t):
n, a, b = map(int, input().split())
s = input()
si = list(s)
for i in range(1, n):
si[i] = s[i]
if s[i - 1] == "1":
si[i] = "1"
si += ["0"]
n += 1
ar = [([0] * 2) for i in range(n)]
ar[0][0] = b
num = 10**20
ar[0][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 FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING VAR LIST STRING VAR NUMBER ASS... |
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 solve(A, n, a, b):
cost = n * a + (n + 1) * b
num_ones = 0
groups_ones = 0
groups_zeros = [0]
on_zeros = True
for i in A:
if i == 0:
if on_zeros:
groups_zeros[-1] += 1
else:
on_zeros = True
groups_ze... | IMPORT FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER IF VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP 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... | t = int(input())
def solve():
n, a, b = map(int, input().split())
dp = [[10**20, 10**20] for i in range(n + 1)]
dp[0][0] = b
s = input()
s += "0"
for i in range(1, n + 1):
if s[i] == "1":
dp[i][1] = min(dp[i - 1][0] + 2 * a + 2 * b, dp[i - 1][1] + a + 2 * b)
elif s[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP 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... | import sys
def main():
(n,) = [int(x) for x in sys.stdin.readline().strip().split()]
INF = 10**20
for _ in range(n):
n, a, b = [int(x) for x in sys.stdin.readline().strip().split()]
s = sys.stdin.readline().strip()
down = [2 * b + a]
up = [b + 2 * b + 2 * a]
for c i... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER 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 FUNC_CALL VAR ASSIGN VAR LIST BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR LIST BIN_OP 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... | from sys import setrecursionlimit as SRL
from sys import stdin
SRL(10**7)
rd = stdin.readline
rrd = lambda: map(int, rd().strip().split())
t = int(rd())
while t:
n, a, b = rrd()
s = str(rd().strip())
ans = (n + 1) * b + a
for i in range(1, n):
if s[i] == "0" and s[i - 1] == "1":
ans... | EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL 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... | from itertools import groupby
def rint():
return int(input())
def rints():
return list(map(int, input().split()))
t = rint()
for _ in range(t):
n, a, b = rints()
s = input()
cost = n * a + (n + 1) * b
for i in range(n + 1):
left1 = i > 0 and s[i - 1] == "1"
right1 = i < n a... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP 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
mod = 10**9 + 7
def ri(flag=0):
if flag == 0:
return [int(i) for i in sys.stdin.readline().split()]
else:
return int(sys.stdin.readline())
for _ in range(ri(1)):
n, pipe_cost, pilar_cost = ri()
take = input()
dp = [
[
999999999999999999999999999999... | IMPORT ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR RETURN FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER 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... | t = int(input())
inf = int(1e18)
for case_num in range(t):
n, a, b = map(int, input().split(" "))
s = input() + "0"
f = [0] * (n + 1)
f[0] = b
g = [0] * (n + 1)
g[0] = inf
for i in range(n):
g[i + 1] = min(f[i] + 2 * a, g[i] + a) + 2 * b
f[i + 1] = (
min(f[i] + a,... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER 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... | for _ in range(int(input())):
n, a, b = map(int, input().split())
description_of_the_road = [int(i) for i in input()]
cost = 0
if 1 in description_of_the_road:
for start, crossroad in enumerate(description_of_the_road):
if crossroad == 0:
cost += a + b
els... | 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 VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR NUMBER VAR BIN_O... |
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 d in range(t):
n, a, b = map(int, input().split())
s = [int(p) for p in list(input())]
c = b
i = 0
z = True
while i < n:
j = i
if z:
while j + 1 < n and s[j + 1] == 0:
j += 1
l = j - i + 1
if l == 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 VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR IF VAR WHILE BIN_OP VAR NUMBER VAR VAR BIN_OP 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 next_one(s, current):
for i in range(current + 1, len(s)):
if int(s[i]) == 1:
return i
return -1
t = int(input())
for i in range(t):
n, a, b = map(int, input().split())
s = input()
changed_dig = False
price = n * a
for j in range(n - 1):
if not changed_dig:
... | FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER RETURN VAR RETURN 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 NUMBER ASSIGN VAR BIN_OP VAR 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... | t = int(input())
an = []
for i in range(t):
n, a, b = map(int, input().split())
s = input()
m = n * a + (n + 1) * b
y = []
l = 0
for i in range(n):
if s[i] == "0":
l += 1
elif l != 0:
y += [l]
l = 0
y += [l]
m += (len(y) - 1 + s.count("... | 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 BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING 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... | t = int(input())
for _ in range(t):
n, a, b = map(int, input().split())
s = input()
INF = 10**18
dp = [([INF] * 2) for i in range(n + 1)]
dp[0][0] = b
for i in range(1, n + 1):
if i < n and (s[i] == "1" or s[i - 1] == "1"):
dp[i][0] = INF
dp[i][1] = min(dp[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 BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP 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... | t = int(input())
for _ in range(t):
n, a, b = map(int, input().split())
s = input()
cnt = 0
first_one = 0
last_one = 0
first_zero = 0
last_zero = 0
diff = 0
for i in range(n):
if s[i] == "1":
if first_one == 0:
first_one = i
last_one = ... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER ASS... |
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 z in range(t):
n, a, b = map(int, input().split())
arr = list(map(int, list(input())))
if not 1 in arr:
print((n + 1) * b + n * a)
continue
dst = 0
need = (2 * a + b - 1) // b
s = 0
first = arr.index(1)
s = first * (a + b) + a + 2 * b + a
for i in... | 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 IF NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR 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... | import sys
read_line = lambda: sys.stdin.readline().strip()
read_intmap = lambda: map(int, read_line().split())
def testCase():
n, a, b = read_intmap()
cross = tuple(map(int, read_line()))
cost = n * a + (n + 1) * b
dp = [([0] * (n + 1)) for i in range(2)]
upper = max(a, b) * n * 20
dp[0][-1]... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL 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... | from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
n, a, b = stdin.readline().strip().split(" ")
n, a, b = int(n), int(a), int(b)
s = stdin.readline().strip()
h1 = a + b
h2 = 2 * a + b
for i in range(1, len(s)):
if s[i] == "0":
if h1 == None:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR FOR VAR 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... | def find_next(A, i, number, n):
while i < n + 1 and A[i] != number:
i += 1
return i
for _ in range(int(input())):
n, a, b = [int(i) for i in input().split()]
A = [int(i) for i in input()]
A.append(0)
cost = b * (n + 1) + n * a
tccost = 2 * a
strtc = a
i = 0
i = find_nex... | FUNC_DEF WHILE VAR BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER RETURN VAR 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 VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN 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... | T = int(input())
for _ in range(T):
n, a, b = map(int, input().split())
s = input()
cost = b
road = 0
previousheight = 0
for c in s:
road += 1
if c == "1":
if road > 2 or road > 1 and previousheight == 0:
optionH = 0
optionL = 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 VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER IF VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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... | for _ in range(int(input())):
n, a, b = (int(s) for s in input().split())
s = input().strip()
ans = (n + 1) * b + n * a
s1 = [i for i in s.split("0") if i != ""]
s2 = [i for i in s.split("1") if i != ""]
for i in range(len(s1)):
if i == 0:
ans += a
if i == len(s1) - 1... | 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 FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR STRING VAR STRING FOR 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... | t = int(input())
for _ in range(t):
n, a, b = map(int, input().split())
s = str(input())
last_seen = "0"
count = 0
counts = []
for i in range(len(s)):
if s[i] == last_seen:
count += 1
else:
counts.append(count)
last_seen = s[i]
coun... | 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 STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN 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 _ in range(t):
n, a, b = map(int, input().split())
s = input()
M = min(a, b)
i = s.find("1")
if i != -1:
Cost = i * (a + b) + a + 2 * b
else:
Cost = n * a + (n + 1) * b
print(Cost)
continue
prev = i
while i < n:
while i < n and... | 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 FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP NUMBER VAR ASSIGN 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... | t = int(input())
for _ in range(t):
n, a, b = [int(x) for x in input().split()]
s = input()
ones = []
for i in range(len(s)):
if s[i] == "1":
ones.append(i)
if len(ones) == 0:
cost = n * a + (n + 1) * b
print(cost)
continue
cost = (ones[0] + 1) * a + (... | 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 LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR 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... | import sys
def naiveSolve():
return
def main():
t = int(input())
allans = []
for _ in range(t):
n, a, b = readIntArr()
s = input()
baseCost = n * a + (n + 1) * b
n += 1
s2 = [0] * n
for i in range(n - 1):
if s[i] == "1":
s2[... | IMPORT FUNC_DEF RETURN FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP 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... | ans = []
round = int(input())
while round > 0:
register = {"high": 0, "half": 0, "low": 0}
[road_len, pp_cost, plr_cost] = list(map(int, input().split()))
road = [int(i) for i in input()]
trade_off = 1
while 2 * pp_cost > trade_off * plr_cost:
trade_off += 1
trade_off += 1
counter = ... | ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR BIN_OP VAR VAR VAR 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... | from sys import stdin
input = stdin.readline
a = []
ans = []
for _ in range(int(input())):
n, p, q = map(int, input().split())
s = input()
l = list(s)
cnt = 0
if s.count("1") == 0:
print(q * (n + 1) + p * n)
continue
a = [0]
b = [1]
for i in range(1, n):
if s[i] ... | ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST 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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER 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... | n = int(input())
for i in range(n):
q = 0
w = 0
su = 0
d, c, st = [int(i) for i in input().split()]
s = input()
k = 0
flag = 1
for i in range(len(s)):
if s[i] == "0":
k += 1
elif flag == 1:
su += 2 * st + c
flag = 2
k = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN 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 VAR NUMBER IF 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... | def next_int():
return int(input())
def next_int_arr():
return map(int, input().split())
INF = 1 << 60
for _ in range(next_int()):
n, a, b = next_int_arr()
s = input()
dp0, dp1 = b, INF
for ch in s:
if ch == "1":
dp0, dp1 = INF, dp1 + 2 * b
else:
dp0, ... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FOR VAR VAR IF VAR STRING ASSIGN VAR VAR VAR BIN_OP VAR BIN_OP 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... | from sys import stdin
def ler():
for line in stdin:
yield line.rstrip()
def converte(string):
res = []
anterior = "0"
q = 0
for s in string:
if anterior == s:
q += 1
else:
res.append(q)
q = 1
anterior = s
res.append(q)
... | FUNC_DEF FOR VAR VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR STRING 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... | for i in range(int(input())):
n, a, b = map(int, input().split())
s = input()
i = 1
cost = a + b + b
prev = 0
while i < n and s[i] == "0":
cost += a + b
i += 1
while i < n - 1:
if s[i] == "1":
j = i
c = 1
while j < n and s[j] == "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 NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR BIN_OP VAR VAR VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING 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... | import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
n, a, b = map(int, input().split())
s = input()
dp = [([0] * 2) for _ in range(n + 1)]
for i in range(n):
if s[i] == "1":
dp[i + 1][0] = 10**18
else:
dp[i + 1][0] = min(dp[i][0] + a + b, dp... | 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 VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER 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... | for _ in range(int(input())):
n, a, b = map(int, input().split())
s = input()
d = list(s)
for i in range(1, n - 1):
if d[i] == "0" and d[i - 1] == "1" and d[i + 1] == "1":
d[i] = "1"
i = 0
while i < n and d[i] == "0":
i += 1
k = n - 1
while k >= 0 and d[k] == ... | 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 FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER 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... |
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
T = int(stdin.readline())
for i in range(0, T):
n, a, b = (int(j) for j in stdin.readline().split())
s = stdin.readline()
cost = (n + 1) * b + n * a
zero = list()
one = list()
zero_count = 0
one_count = 0
for j in s:
if j == "0":
zero_count += 1... | 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 BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR 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... | def solve():
l = list(map(int, input().strip().split()))
s = input()
n = l[0]
a = l[1]
b = l[2]
dp = []
for _ in range(n + 10):
dp.append([float("inf"), float("inf")])
dp[0][0] = b
dp[0][1] = float("inf")
for i in range(n):
if s[i] == "0":
dp[i + 1][0]... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR 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())
while t:
n, a, b = [int(x) for x in input().split()]
road = input()
what = True
j = 0
answer = 0
first = 0
while j < n and road[j] != "1":
j += 1
first = j
for i in range(j + 1, n):
if road[i] == "0" and what:
x = i - j
answer ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF 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... | for _ in range(int(input())):
n, a, b = map(int, input().split())
s = input()
first_1 = s.find("1")
last_1 = s.rfind("1")
cost = n * a + (n + 1) * b
if first_1 > -1:
cost += 2 * a
cost += (last_1 - first_1 + 2) * b
groups = []
cur = ""
for c in s[first_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 FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR VAR BIN_OP 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())
l = input()
x = 0
y = a + b
for i in range(1, n):
if l[i] == "1":
x = 10000000000000000
c = x
if l[i] == "0":
x = min(x + a + b, y + 2 * a + b)
y = min(c + 2 * a + 2 * b, y... | 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 BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL 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... | for t in range(int(input())):
n, a, b = [int(j) for j in input().split()]
ans = 0
prev = -1
last_state = 0
l = [int(j) for j in list(input())]
prev = 0
p = [(0) for i in range(n)]
flag = False
for i in range(n)[::-1]:
if l[i] == 1 and flag:
p[i] = prev
... | 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_C... |
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 = map(int, input().split())
s = input()
f = 0
cost = b
cost2 = 0
for i in range(n):
if s[i] == "0":
if f:
cost2 += a + 2 * b
cost += a + b
if i + 1 < n:
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 ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR IF BIN_OP 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 test_num in range(T):
n, a, b = map(int, input().split())
st = 0
ln = input()
per = 0
cx = 0
cn = 0
i = 0
while i < len(ln):
if ln[i] == "1":
if cn > 0:
if per > 0:
st = st + min(
cn * 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 NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER IF VAR NUMBER 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().rstrip().split())
s = input() + "0"
m1, m2 = b, float("inf")
for i in range(n):
m3 = min(m1 + 2 * a + 2 * b, m2 + a + b * 2)
if s[i + 1] == "0" and s[i] == "0":
m1 = min(m1 + a + b, m2 + 2 * a + b)
else:
... | 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 FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR BIN_OP 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... | T = int(input())
for k in range(T):
n, a, b = map(int, input().split())
s = input()
dp = [[0, 0] for k in range(n + 1)]
dp[0][0] = b
dp[0][1] = float("inf")
for l in range(1, n + 1):
if s[l - 1] == "0":
dp[l][0] = min(dp[l - 1][0] + a + b, dp[l - 1][1] + 2 * a + 2 * b)
... | 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 NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR ASSIGN VAR NUMBER NUMBER FUNC_CALL VAR STRING FOR VAR FUNC_CALL 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... | def handle_case(n, pipe, pillar, s):
num_pipe = 0.5
num_pillar = 1
last = "down"
def increase_by(num_pipe, pipe_inc, num_pillar, pillar_inc):
num_pipe += pipe_inc
num_pillar += pillar_inc
return num_pipe, num_pillar
def is_good_to_down(i):
nearest_one_indx = s[i:].f... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FUNC_DEF VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR STRING IF VAR NUMBER RETURN STRING VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP VAR VAR 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... | t = int(input())
for nt in range(t):
n, a, b = map(int, input().split())
s = input()
group = []
current = "0"
count = 0
for i in range(n):
if s[i] == current:
count += 1
else:
group.append(count)
count = 1
if current == "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 STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR STRING 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... | import sys
input = sys.stdin.readline
def getInt():
return int(input())
def getVars():
return map(int, input().split())
def getArr():
return list(map(int, input().split()))
def getStr():
return input().strip()
t = getInt()
for _ in range(t):
n, a, b = getVars()
s = getStr()
p = s.... | IMPORT ASSIGN VAR VAR 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 VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN 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... | x = int(input())
for i in range(x):
n, a, b = map(int, input().split())
queue = input()
first = queue.find("1")
if first == -1:
print(a * n + b * (n + 1))
continue
backqueue = queue[::-1]
last = n - 1 - backqueue.find("1")
save = (2 * a - 1) // b + 2
conseczeroes = 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 FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR 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... | for _ in range(int(input())):
N, pipe, pillar = map(int, input().split())
S = input()
Bins = []
flag = True
for i in range(len(S)):
if S[i] == "0" and flag:
flag = False
O = i
elif S[i] == "1" and not flag:
flag = True
Bins.append((O, i... | 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 LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR VAR STRING VAR ASSIGN VAR NUMBER EXPR 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())
while t != 0:
t -= 1
n, a, b = map(int, input().split())
s = input()
dp = [[(10**20) for _ in range(n + 1)] for _ in range(2)]
dp[0][0] = b
for i in range(n):
if s[i] == "0":
dp[0][i + 1] = min(dp[0][i] + a + b, dp[1][i] + 2 * a + b)
dp[1][i + 1] ... | 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 ASSIGN VAR BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING 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 query in range(t):
n, a, b = map(int, input().split())
s = input()
A = list()
ln = 1
j = 1
while j < n:
if s[j] == s[j - 1]:
ln += 1
else:
A.append(ln)
ln = 1
j += 1
A.append(ln)
if len(A) == 1:
prin... | 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 FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER 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... | def int_multiple():
return [int(c) for c in input().split()]
def int_single():
return int(input())
def str_multiple():
return [c for c in input().split()]
def str_single():
return input()
T = int_single()
res = []
for i in range(T):
n, pipe, pillar = int_multiple()
s = str_single()
r... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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... | t = int(input())
for _ in range(t):
n, a, b = list(map(int, input().split()))
s = input()
a1 = 0
start = 1
total = 0
if "1" in s:
for i in range(1, n - 1):
if s[i] == "0":
start += 1
else:
break
total += (start + 1) * a + st... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER 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 = [int(i) for i in input().split()]
data = input() + "0"
inf = 1 << 50
dp = [[0, inf]]
for i in range(1, n + 1):
dp.append([0, 0])
if data[i] == "0" and data[i - 1] == "0":
dp[-1][0] = min(dp[-2][0], dp[-2][1] + a)
dp[-1][... | 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 BIN_OP FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER IF VAR VAR STRING... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.