목록Algorithm/BackJoon (20)
S E P H ' S
1261번: 알고스팟 첫째 줄에 미로의 크기를 나타내는 가로 크기 M, 세로 크기 N (1 ≤ N, M ≤ 100)이 주어진다. 다음 N개의 줄에는 미로의 상태를 나타내는 숫자 0과 1이 주어진다. 0은 빈 방을 의미하고, 1은 벽을 의미 www.acmicpc.net from collections import deque dx = [-1, 1, 0, 0] dy = [0, 0, -1, 1] m, n = map(int, input().split()) maze = [list(map(int, input())) for _ in range(n)] crush = [[-1]*m for _ in range(n)] q = deque() q.append((0, 0)) crush[0][0] = 0 while q: x, y = ..
https://www.acmicpc.net/problem/13300 13300번: 방 배정 표준 입력으로 다음 정보가 주어진다. 첫 번째 줄에는 수학여행에 참가하는 학생 수를 나타내는 정수 N(1 ≤ N ≤ 1,000)과 한 방에 배정할 수 있는 최대 인원 수 K(1 < K ≤ 1,000)가 공백으로 분리되어 www.acmicpc.net 1. 성별 / 학년으로 구분 지을 수 있도록 2차원 배열 선언 2. 성별 / 학년 별로 1씩 증가 3. 성별 / 학년 별로 최대 인원 수인 K로 나눈 값을 올림한다 ( 1명인 방도 가능 하기 때문 ) 4. 방 수를 출력 한다. import math N, K = map(int, input().split()) student = [[0]*7 for _ in range(3)] ..
https://www.acmicpc.net/problem/10163 10163번: 색종이 평면에 색깔이 서로 다른 직사각형 모양의 색종이 N장이 하나씩 차례로 놓여진다. 이때 색종이가 비스듬하게 놓이는 경우는 없다. 즉, 모든 색종이의 변은 서로 평행하거나, 서로 수직이거나 둘 www.acmicpc.net 1. 색종이 수(N) 만큼 반복. 이 때, 색종이 번호로 cnt를 증가 시킬 것이므로 1부터 N+1까지 반복한다. 2. 색종이 영역만큼 반복하여 색종이 번호를 2차원 배열에 저장 3. 반복문을 실행하여 카운트 N = int(input()) board = [[0]*101 for _ in range(101)] for n in range(1, N+1): arr = list(map(int, input().sp..
1436번: 영화감독 숌 666은 종말을 나타내는 숫자라고 한다. 따라서, 많은 블록버스터 영화에서는 666이 들어간 제목을 많이 사용한다. 영화감독 숌은 세상의 종말 이라는 시리즈 영화의 감독이다. 조지 루카스는 스타 www.acmicpc.net N = int(input()) num = 666 cnt = 0 while 1: if '666' in str(num): cnt += 1 if cnt == N: print(num) break num += 1 666을 포함하는 숫자 중에 몇 번째 숫자인지를 출력하는 문제이다. 1. num 안에 666이 있다면 cnt를 증가 2. cnt 가 N과 같다면 num을 출력하고 break 3. 모두 아니면 num을 1씩 증가 4. 반복한다