https://www.acmicpc.net/problem/2563
μ½λ
paper_list = [[0 for i in range(100)] for j in range(100)]
times = int(input())
for _ in range(times):
x, y = map(int, input().split())
for row in range(x, x+10):
for col in range(y, y+10):
paper_list[row][col] = 1
result = 0
for num in paper_list:
result += num.count(1)
print(result)
μ½λ μ€λͺ
1. paper_listλ₯Ό λͺ¨λ 0μ κ°μ κ°μ§ 100 * 100μ 2μ°¨μ λ°°μ΄λ‘ μ΄κΈ°ν
2. μ λ ₯ λ°μ μ’ μ΄ κ°―μ(times)λ§νΌ λ°λ³΅λ¬Έ μ€ν
3. μ λ ₯λ°μ κ° μμ’ μ΄μ μ’μΈ‘ νλ¨ x, y μ’νλ₯Ό x, yμ μ μ₯
4. paper_list[x][y] κ°μ x ~ x+10, y ~ y+10λ²μμμ paper_listμ 0 κ°μ 1λ‘ λ³κ²½
μ¦, μμ’ μ΄μ μ’μΈ‘ νλ¨μ’νμμ μμνμ¬ μ°μΈ‘ μλ¨κΉμ§ 1λ‘ λ³κ²½
5. resultκ° 0μΌλ‘ μ΄κΈ°ν ν, paper_list 2μ°¨μ λ°°μ΄ λ΄μ κ° λ¦¬μ€νΈλ₯Ό λμμΌλ‘ 1μ κ°μ resultμ μΆκ°
6. print(result)
'python' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[baekjoon] 10789λ² μΈλ‘μ½κΈ° Python (1) | 2023.10.14 |
---|---|
[programmers] λ¬Έμμ΄ μ¬λ¬λ² λ€μ§κΈ° (python) (8) | 2023.10.11 |
[python] tkinter miles km converter / tkinter λ§μΌ ν¬λ‘λ―Έν° λ³νκΈ° (3) | 2023.10.10 |
[python] *args κ³Ό **kwargs (6) | 2023.10.10 |
[python] list comprehension 리μ€νΈ μ»΄ν리ν¨μ (0) | 2023.10.09 |