[백준] 17140번 이차원 배열과 연산- 파이썬
·
알고리즘 공부/구현
https://www.acmicpc.net/problem/17140 17140번: 이차원 배열과 연산 첫째 줄에 r, c, k가 주어진다. (1 ≤ r, c, k ≤ 100) 둘째 줄부터 3개의 줄에 배열 A에 들어있는 수가 주어진다. 배열 A에 들어있는 수는 100보다 작거나 같은 자연수이다. www.acmicpc.net import sys import copy r, c, k= map(int,sys.stdin.readline().split()) num_list = [] r -=1 c -= 1 for i in range(3): num_list.append(list(map(int,input().split()))) def r_cal(num_list): tmp = [] max_len = 0 for i in r..
[백준] 14890번 경사로- 파이썬
·
알고리즘 공부/구현
https://www.acmicpc.net/problem/14890 14890번: 경사로 첫째 줄에 N (2 ≤ N ≤ 100)과 L (1 ≤ L ≤ N)이 주어진다. 둘째 줄부터 N개의 줄에 지도가 주어진다. 각 칸의 높이는 10보다 작거나 같은 자연수이다. www.acmicpc.net import sys n, l= map(int, sys.stdin.readline().split()) graph = [] for i in range(n): graph.append(list(map(int,sys.stdin.readline().split()))) def check_garo(i): # 가로 라인 확인 # c는 경사로를 둔 곳이다. c = [0 for _ in range(n)] for j in range(n-1)..
[백준] 14499번 주사위 굴리기- 파이썬
·
알고리즘 공부/구현
https://www.acmicpc.net/problem/14499 14499번: 주사위 굴리기 첫째 줄에 지도의 세로 크기 N, 가로 크기 M (1 ≤ N, M ≤ 20), 주사위를 놓은 곳의 좌표 x, y(0 ≤ x ≤ N-1, 0 ≤ y ≤ M-1), 그리고 명령의 개수 K (1 ≤ K ≤ 1,000)가 주어진다. 둘째 줄부터 N개의 줄에 지 www.acmicpc.net import sys n, m, x, y, k= map(int, sys.stdin.readline().split()) graph = [] dice = [ [0], [0,0,0], [0], [0]] def rol_dice(a): if a == 1: tmp = dice[3][0] dice[3][0] = dice[1][2] dice[1][..
[백준] 17144번 미세먼지 안녕!- 파이썬
·
알고리즘 공부/구현
https://www.acmicpc.net/problem/17144 17144번: 미세먼지 안녕! 미세먼지를 제거하기 위해 구사과는 공기청정기를 설치하려고 한다. 공기청정기의 성능을 테스트하기 위해 구사과는 집을 크기가 R×C인 격자판으로 나타냈고, 1×1 크기의 칸으로 나눴다. 구사 www.acmicpc.net import sys r,c,t = map(int,sys.stdin.readline().split()) room = [] for i in range(r): room.append(list(map(int, sys.stdin.readline().split()))) clean_air = [] dx = [-1,0,1,0] dy = [ 0,-1,0,1] def div_dust(): tmp = [[0] *c ..
[백준] 15685번 드래곤 커브- 파이썬
·
알고리즘 공부/구현
https://www.acmicpc.net/problem/15685 15685번: 드래곤 커브 첫째 줄에 드래곤 커브의 개수 N(1 ≤ N ≤ 20)이 주어진다. 둘째 줄부터 N개의 줄에는 드래곤 커브의 정보가 주어진다. 드래곤 커브의 정보는 네 정수 x, y, d, g로 이루어져 있다. x와 y는 드래곤 커 www.acmicpc.net import sys n = int(sys.stdin.readline()) graph = [[0]*101 for _ in range(101)] dx = [1,0,-1,0] dy = [0,-1,0,1] def check_square(graph): count = 0 for i in range(len(graph)-1): for j in range(len(graph[0])-1):..
[백준] 14891번 톱니바퀴- 파이썬
·
알고리즘 공부/구현
https://www.acmicpc.net/problem/14891 14891번: 톱니바퀴 첫째 줄에 1번 톱니바퀴의 상태, 둘째 줄에 2번 톱니바퀴의 상태, 셋째 줄에 3번 톱니바퀴의 상태, 넷째 줄에 4번 톱니바퀴의 상태가 주어진다. 상태는 8개의 정수로 이루어져 있고, 12시방향부터 www.acmicpc.net import sys def turn_arround(cir): temp = cir[-1] for i in range(len(cir)-1, -1,-1): cir[i] = cir[i-1] cir[0] = temp return cir def reverse_turn(cir): temp = cir[0] for i in range(1,len(cir)): cir[i-1] = cir[i] cir[-1] = ..
[백준] 21610번 마법사 상어와 비바라기- 파이썬
·
알고리즘 공부/구현
https://www.acmicpc.net/problem/21610 21610번: 마법사 상어와 비바라기 마법사 상어는 파이어볼, 토네이도, 파이어스톰, 물복사버그 마법을 할 수 있다. 오늘 새로 배운 마법은 비바라기이다. 비바라기를 시전하면 하늘에 비구름을 만들 수 있다. 오늘은 비바라기 www.acmicpc.net from collections import deque import sys n,m = map(int,sys.stdin.readline().split()) basket = [] for _ in range(n): basket.append(list(map(int,sys.stdin.readline().split()))) dx = [ 0, -1, -1, -1, 0, 1, 1, 1] dy = [-1, ..
[백준] 21608번 상어 초등학교 - 파이썬
·
알고리즘 공부/구현
https://www.acmicpc.net/problem/21608 21608번: 상어 초등학교 상어 초등학교에는 교실이 하나 있고, 교실은 N×N 크기의 격자로 나타낼 수 있다. 학교에 다니는 학생의 수는 N2명이다. 오늘은 모든 학생의 자리를 정하는 날이다. 학생은 1번부터 N2번까지 번호 www.acmicpc.net n = int(input()) seat = [[0] * n for _ in range(n)] student = {} dx = [0, 0, 1, -1] dy = [1, -1, 0, 0] for i in range(n**2): like_input = list(map(int, input().split())) student[like_input[0]] = like_input[1:] max_x =..