Again, I challenged AtCoder Beginners Contest 166 with Python! !! I was late to notice that I made a mistake in the output of the B problem, and I lost a lot ... Anyway, ABC for 2 consecutive days is good! !!
A.py
s = input()
if s == "ABC":
print("ARC")
else:
print("ABC")
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.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)
Recommended Posts