20240702

1918A. Brick Wall

maximize the number of horizontal bricks <=> use as many 1*2 (smallest) bricks as possible

m is even => (horizontal, vertical) = (n * m // 2, 0)

m is odd => (horizontal, vertical) = (n * (m - 1) // 2, 0), for the last 3 columns, we use 1*3 bricks so that we don't need to use vertical bricks.

for _ in range(int(input())):
    n, m = map(int, input().split())
    if m % 2 == 0:
        print(n * m // 2)
    else:
        print(n * (m - 1) // 2)

1917A. Least Product

def solve(n: int, a: list[int]) -> tuple[int, list[tuple[int, int]]]:
    if 0 in a:
        return 0, []

    if sum(1 for x in a if x < 0) % 2 == 0:
        return 1, [(1, 0)]

    return 0, []


for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))
    k, ops = solve(n, a)
    print(k)
    for i in range(k):
        print(f"{ops[i][0]} {ops[i][1]}")

1922A. Tricky Template

Accordingly, the string doesn't match the template if the condition doesn't hold for at least one i.

To make the string c does not match the template, we only need one position that does not meet the criteria.

When c[i] equals to a[i] or b[i], we cannot create a template that a[i] and b[i] match and c[i] does not.

a[i] = “a”, b[i] = “b”, c[i] = “c” => t[i] = “C”

a[i] = “a”, b[i] = “b”, c[i] = “a” => cannot make a[i] meet the criteria and c[i] does not as they are the same.

def exists(n: int, a: str, b: str, c: str) -> bool:
    for i in range(n):
        if c[i] != a[i] and c[i] != b[i]:
            return True
    return False


for _ in range(int(input())):
    n = int(input())
    a = input()
    b = input()
    c = input()

    if exists(n, a, b, c):
        print("YES")
    else:
        print("NO")

Since tracking calories intake did not work this time and I'm getting overweight, let's try low carbohydrate diet for a few months.

MCT oil is not sold at the nearest Safeway. I might want to check Target tomorrow.

Eggs 20g salad 20g Sashimi 5g Meat stick 0g

Total carbohydrate 45g (< 60g)


TODO:


index 20240701 20240703