1
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?

ABC424をPythonで(A~C+α)

Posted at

AtCoder × Engineer Guild オンサイトコンテスト ~集結!高レート人材~予選(AtCoder Beginner Contest 424)の解答等の速報的まとめ

A問題

どれか2つが一致すればいい

A
a, b, c = map(int, input().split())

print("Yes" if a == b or b == c or c == a else "No")

B問題

同じ問題が解かれないので、正解の回数を記録するだけでいい

B
n, m, k = map(int, input().split())
asked = {i:0 for i in range(n + 1)}
complete = list()

for _ in range(k):
    a, _ = map(int, input().split())
    asked[a] += 1
    if asked[a] >= m:
        complete.append(a)

print(*complete)

C問題

bfsでスキル取得できるか調べる

C
from collections import deque

n = int(input())
edge = [[] for _ in range(n)]
skil = deque()
ans = [False] * n
for i in range(n):
    a, b = map(lambda x:int(x) - 1, input().split())
    if a == b == -1:
        skil.append(i)
        ans[i] = True
    else:
        edge[a].append(i)
        edge[b].append(i)

while skil:
    now = skil.popleft()
    for to in edge[now]:
        if ans[to]:
            continue
        else:
            ans[to] = True
            skil.append(to)

print(sum(ans))

D問題

dpとかの処理がわからなかった
貪欲に

##
##

?##
###
##?

の二パターンの時に真ん中を塗るのを考えたがダメだった

E問題

大きいほうから何回切ることになるかは計算できそうだったが$k=10^9$で間に合わせつつ$x$番目を求める方法がわからなかった

1
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
1
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?