0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ABC443をPythonで

Posted at

デンソークリエイトプログラミングコンテスト2026(AtCoder Beginner Contest 443)の解答等の速報的まとめ

A問題

sを付けるだけ

A
print(input()+"s")

B問題

シミュレーション
最大パターン$(n=1, k=10^8)$でも14000ぐらいなので問題ないです

B
n, k = map(int, input().split())
cnt = 0
year = 0
while cnt < k:
    cnt += n + year
    if cnt >= k:
        break
    else:
        year += 1

print(year)

C問題

差分計算を順にやっていく

C
n, t = map(int, input().split())
a = list(map(int, input().split()))

a.append(t)

ans = 0
last = -100
for a_i in a:
    if last + 100 <= a_i:
        ans += a_i - (last + 100)
        last = a_i

print(ans)

D問題

何度やっても$O(n^2)$から下げられなかった

E問題

下から移動できるかと壁を消せるかを持ちながら探索する

E
wall = "#"

for _ in range(int(input())):
    n, c = map(int, input().split())
    s = [input() for _ in range(n)]
    c -= 1
    # [移動できるか、壁を消せるか]
    dp = [[False, True] for _ in range(n)]

    for i, s_i in enumerate(s[-1]):
        if s_i == wall:
            dp[i][1] = False
        if i == c:
            dp[i][0] = True

    for s_i in s[:-1][::-1]:
        new_dp = [[False, True] for _ in range(n)]
        for x, s_x in enumerate(s_i):
            can_access = False
            for i in [x - 1, x, x + 1]:
                if i < 0 or n <= i:
                    continue
                if dp[i][0]:
                    can_access = True
            if s_x == wall:
                if can_access and dp[x][1]:
                   new_dp[x] = [True, True]
                else:
                    new_dp[x] = [False, False]
            else:
                new_dp[x] = [can_access, dp[x][1]]
        dp = new_dp

    for dp_i in dp:
        print(1 if dp_i[0] else 0, end="")
    print()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?