Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- 자연어처리
- 비트마스킹
- 구현
- Geocoding
- 전처리
- 지진대피소
- 누적합
- geopy
- xmltodict
- 유사도
- dp
- 공공데이터
- 그래프탐색
- 백준
- NLP
- 우선순위큐
- 재귀
- 그래프이론
- cosine
- 건축물대장정보
- pandas
- 유클리드
- 그리디
- 분할정복
- GroupBy
- 깊이우선탐색
- TF-IDF
- 수학
- 코사인유사도
- 너비우선탐색
Archives
- Today
- Total
정리용
[백준 1780] 파이썬 - 종이의 개수 본문
1. 코드 설명
n = int(input())
arr = [list(map(int, input().split())) for _ in range(n)]
minus = 0
plus = 0
zero = 0
def cut (x, y, n) :
global minus, plus, zero
for i in range(x, x+n):
for j in range( y, y+n):
if arr[x][y] != arr[i][j]:
# 9 등분으로 나누고 시작점마다 함수 실행
for w in range (3) :
for e in range (3) :
cut(x + n // 3 * w, y+ n // 3 * e, n // 3)
return
if arr[x][y] == 1 :
plus += 1
elif arr[x][y] == -1 :
minus += 1
else :
zero += 1
cut(0,0,n)
print(minus)
print(zero)
print(plus)
2. 주의사항
'알고리즘 > 백준' 카테고리의 다른 글
| [백준 5525] 파이썬 - ioioi (0) | 2021.12.30 |
|---|---|
| [백준 1992] 파이썬 - 쿼드트리 (0) | 2021.12.27 |
| [백준] (0) | 2021.12.20 |
| [백준 1904] 파이썬 - (0) | 2021.12.19 |
| [백준 1010] (0) | 2021.12.18 |
Comments