20240602

1900B. Laura and Operations

Editorial

Why is it tagged as dp when the solution does not use dynamic programming?? I'm kinda triggered.

20240725: At least, there are recursive relationships.

My guess is that, using C++ or other fast languages can solve this problem even with dynamic programming approaches. Therefore, it's tagged dp although dynamic programming is not the optimal solution.

Similar things happened when I was in college. I needed to do dynamic programming when solving the problem with Python, but other teams solved the problem by just brute forcing with C++.

Take3away

for _ in range(int(input())):
    a, b, c = map(int, input().split())

    print(
        1 if b % 2 == c % 2 else 0,
        1 if a % 2 == c % 2 else 0,
        1 if a % 2 == b % 2 else 0,
        sep=" ",
    )

(2, 2, 1) can be

The parity of each number changes after each operation. That means, two numbers always have the same parity if their parities are the same at the beginning. Otherwise, two numbers have the different parity through the operations.

When two numbers have the same parity, the other one can be left after the operations.

(3, 7, 4)

-> (4, 6, 5)

-> (5, 5, 6)

-> (0, 0, 11)

If two numbers have the same parity, but one is bigger than the other, following operations can make both numbers 0.

  1. Reduce the difference by 2, by decreasing the bigger number and increasing the others.
  2. Once two numbers have the same numbers, decreasing the two numbeers and increasing the other can make the two numbers 0.

Therefore, the solution code is very simple as shown above.


Sushi 800 Avocado 200 yogurt 800 Protein shake 200

Total 2000 kcal


TODO:


index 20240601 20240603