2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ABC166をPythonで A~C問題

Posted at

#はじめに
今回もAtCoder Beginners Contest 166にPythonで挑戦しました!!
B問題の出力を間違えているのに気づくのが遅れ、かなりロスしてしましました…
にしても、2日連続のABCはいいですね!!

#A問題

A.py
s = input()
if s == "ABC":
    print("ARC")
else:
    print("ABC")

#B問題

B.py
n, k = map(int, input().split())
d = [0] * k
sunuke = {}
for i in range(n):
    sunuke.setdefault(str(i),0)
for i in range(n):
    sunuke[str(i)] = 0

for i in range(k):
    d[i] = int(input())
    A = list(map(int, input().split()))
    for j in range(d[i]):
        sunuke[str(A[j]-1)] += 1
ans = list(sunuke.values()).count(0)
print(ans)




#C問題

C.py
n, m = map(int, input().split())
h = list(map(int, input().split()))
cnt = [0] * n
chk = [0] * n
ans = 0

for i in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        cnt[a-1] += 1
    if h[a-1] < h[b-1]:
        cnt[b-1] += 1
    chk[a-1] += 1
    chk[b-1] += 1

for i in range(n):
    if cnt[i] == chk[i]:
        ans += 1

print(ans)
2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?