Beginner ABC157 (Python)

Click here for the contest page

https://atcoder.jp/contests/abc157

n = int(input())
ans = n//2 + 1 if n % 2 else n//2
print(ans)

The output was classified according to whether n was even or odd. Submission https://atcoder.jp/contests/abc157/submissions/10518520 Reference: Ternary operator (Python)

B

a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
mark = [[False, False, False] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:mark[i][j] = True

ans = 'No'
for i in range(3):
    if all(mark[i]):
        ans = 'Yes'
        break      
for j in range(3):
    if mark[0][j] and mark[1][j] and mark[2][j]:
        ans = 'Yes'
        break
if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[2][0]): ans = 'Yes'
print(ans)

I made a two-dimensional list mark that shows whether or not it was marked, and marked it as True. (If you mark while receiving the input, you don't need the list ʻa` to store the input.) After that, check if horizontal bingo, vertical bingo, and diagonal bingo are established.

Submission https://atcoder.jp/contests/abc157/submissions/10444407

C

n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]
ans = float('inf')
k = 0
if n == 2: k = 10
elif n == 3: k = 100
for i in range(k, 1000):
    flg = True
    for s, c in sc:
        if list(str(i))[s-1] == str(c): continue
        flg = False
    if flg:
        ans = i
        break
if ans == float('inf'): ans = -1
print(ans)

Since N and M are small, I tried all the numbers in the range from the smaller one, and if there was a corresponding one, I exited the loop and output.

Submission: https://atcoder.jp/contests/abc157/submissions/10518841

D, E and F

I would like to add it if I can AC.

Recommended Posts

Beginner ABC154 (Python)
Beginner ABC156 (Python)
Beginner ABC155 (Python)
Beginner ABC157 (Python)
python beginner memo (9.2-10)
AtCoder ABC 174 Python
[Beginner] Python array
AtCoder ABC187 Python
AtCoder ABC188 Python
[Beginner] Python functions
PyQ ~ Python Beginner ~
Python beginner memo (2)
AtCoder ABC 175 Python
Python beginner Zundokokiyoshi
Python beginner Atcoder memo @ KEYENCE 2020, ABC problem
Solve ABC169 in Python
ABC147 C --HonestOrUnkind2 [Python]
AtCoder ABC 177 Python (A ~ E)
ABC168
Solve AtCoder ABC166 with python
ABC164
ABC163 C problem with python3
python super beginner tries scraping
AtCoder ABC 178 Python (A ~ E)
Python
Atcoder ABC164 A-C in Python
Solve ABC176 E in Python
ABC memorandum [ABC163 C --managementr] (Python)
Python beginner launches Discord Bot
ABC174
AtCoder ABC 176 Python (A ~ E)
Atcoder ABC167 A-D in Python
Atcoder ABC165 A-D in Python
Atcoder ABC166 A-E in Python
ABC175
ABC170
AtCoder ABC 182 Python (A ~ D)
Web scraping beginner with python
ABC188 C problem with python3
[Python beginner] Update pip itself
Solve AtCoder ABC 186 with Python
Atcoder Beginner Contest 152 Kiroku (python)
ABC182
ABC153
ABC187 C problem with python
Atcoder ABC169 A-E in Python
AtCoder ABC177 A-D in python
Solve ABC163 A ~ C with Python
ABC127 A, B, C Explanation (python)
ABC166 in Python A ~ C problem
Let's play with Excel with Python [Beginner]
[Python beginner] Divide one list (5 lines).
Solve ABC168 A ~ C with Python
ABC memorandum [ABC161 C --Replacing Integer] (Python)
ABC memorandum [ABC158 C --Tax Increase] (Python)
Python beginner tried 100 language processing knock 2015 (05 ~ 09)
Solved AtCoder ABC 114 C-755 with Python3
Solve ABC162 A ~ C with Python
Solve ABC167 A ~ C with Python
ABC128 A, B, C commentary (python)
Solve ABC158 A ~ C with Python