Just write.
A = input()
S = input()
result = ''
for c in S:
    if c in '0123456789':
        result += A[int(c)]
    else:
        result += c
print(result)
The moment I saw the problem statement, it became ★ 1.5 !?. When I calculated 2 3 0 and 2 3 1 by hand, the numbers were the same in every order, so I wondered if the order was irrelevant. Write the code to process in order from AC.
T = int(input())
m = 1000000007
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    t = 0
    for a in A:
        t = t * a + (t + a)
        t %= m
    print(t)
If you have 100 yen at the beginning, you can change the number freely, so in the end it was only possible to divide X + Y + Z by 3 people and make it the same number.
X, Y, Z = map(int, input().split())
if (X + Y + Z) % 3 == 0:
    print('Yes')
else:
    print('No')
Initialize an array of length W to the initial value H, take the minimum value of Y -1, and subtract the reduced number from H * W each time to find the answer .... W ≤ 10 Died at 9 (explosion). AC.
from sys import stdin
readline = stdin.readline
H, W, Q = map(int, readline().split())
c = H * W
t = {}
result = []
for _ in range(Q):
    Y, X = map(int, readline().split())
    t.setdefault(X - 1, H)
    p = t[X - 1]
    t[X - 1] = min(t[X - 1], Y - 1)
    c -= p - t[X - 1]
    result.append(c)
print(*result, sep='\n')
        Recommended Posts