ABC166 in Python A ~ C problem

Introduction

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 problem

A.py


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

B problem

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 problem

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

ABC166 in Python A ~ C problem
Solve ABC036 A ~ C in Python
Solve ABC037 A ~ C in Python
ABC163 C problem with python3
ABC188 C problem with python3
ABC187 C problem with python
Challenge AtCoder (ABC) 164 with Python! A ~ C problem
Solve ABC163 A ~ C with Python
Solve ABC168 A ~ C with Python
Solve ABC162 A ~ C with Python
Solve ABC167 A ~ C with Python
ABC128 A, B, C commentary (python)
Solve ABC158 A ~ C with Python
ABC126 A, B, C Explanation (python)
Solve Atcoder ABC176 (A, B, C, E) in Python
AtCoder ABC151 Problem D Speed comparison in C ++ / Python / PyPy
Algorithm in Python (ABC 146 C Binary Search
[AtCoder] Solve ABC1 ~ 100 A problem with Python
Solve ABC165 A, B, D in Python
Next Python in C
Solve ABC169 in Python
C API in Python 3
ABC147 C --HonestOrUnkind2 [Python]
Try to calculate a statistical problem in Python
Call a Python script from Embedded Python in C ++ / C ++
I tried adding a Python3 module in C
Extend python in C ++ (Boost.NumPy)
AtCoder ABC 177 Python (A ~ E)
Take a screenshot in Python
Create a function in Python
Create a dictionary in Python
AtCoder ABC 178 Python (A ~ E)
Atcoder ABC164 A-C in Python
ABC129 A, B, C commentary
ABC memorandum [ABC163 C --managementr] (Python)
AtCoder ABC 176 Python (A ~ E)
Atcoder ABC167 A-D in Python
Binary search in Python / C ++
Solve ABC175 D in Python
Make a bookmarklet in Python
Atcoder ABC165 A-D in Python
Atcoder ABC166 A-E in Python
AtCoder ABC 182 Python (A ~ D)
Draw a heart in Python
Atcoder ABC169 A-E in Python
AtCoder ABC177 A-D in python
Try to make a Python module in C language
Try embedding Python in a C ++ program with pybind11
AtCoder Beginner Contest 166 A Explanation of Problem "A? C" (Python3, C ++, Java)
Maybe in a python (original title: Maybe in Python)
Write a binary search in Python
ABC memorandum [ABC159 C --Maximum Volume] (Python)
Write a table-driven test in C
[python] Manage functions in a list
[AtCoder explanation] Control ABC180 A, B, C problems with Python!
[AtCoder explanation] Control ABC188 A, B, C problems with Python!
Hit a command in Python (Windows)
[Note] Project Euler in Python (Problem 1-22)
Create a DI Container in Python
Solve ABC166 A ~ D with Python
AtCoder Beginner Contest 167 A Problem "Registration" Explanation (Python3, C ++, Java)