Algorithm/Implementaion20 [백준] 1913번 달팽이 깡 구현 그 자체... BFS에서 길 찾기 했던거 약간 응용함.. 쓰읍.... 가독성을 위해 코드 길이가 길어졌는데.. 썩 효율적이지도 못한거 같다.. N = int(input()) findNum = int(input()) snail = [[0] * N for _ in range(N)] direction = [[1, 0], [0, 1], [-1, 0], [0, -1]] # 하 우 상 좌 diCurrent = 0 cX = 0 cY = 0 findX = 0 findY = 0 nN = N * N while True: if snail[cY][cX] == 0: snail[cY][cX] = nN nN -= 1 if nN == 0: break cY += direction[diCurrent][0] cX += direc.. 2020. 11. 26. [백준] 1032번 명령 프롬프트 쉬운 문제.. import sys N = int(sys.stdin.readline()) dataList = [] for i in range(N): dataList.append(sys.stdin.readline().strip()) for i in range(len(dataList[0])): flag = 0 temp = dataList[0][i] for j in range(1, N): if dataList[j][i] != temp: print("?", end="") flag = 1 break if not flag: print(dataList[0][i], end="") 2020. 11. 25. [백준] 1966번 프린터 큐 쉬운 문제.. import sys T = int(sys.stdin.readline()) for i in range(T): ans = 0 N, M = map(int, sys.stdin.readline().split()) tc = list(map(int, sys.stdin.readline().split())) tm = [0] * N tm[M] = 1 popData = max(tc) while True: tempM = tm.pop(0) tempC = tc.pop(0) if tempC == popData: ans += 1 if tempM == 1: break popData = max(tc) else: tc.append(tempC) tm.append(tempM) print(ans) 2020. 11. 25. [백준] 7568번 덩치 쉬운 문제 import sys N = int(sys.stdin.readline()) dataList = [] for i in range(N): dataList.append(list(map(int, sys.stdin.readline().split()))) for i in range(N): count = 1 for j in range(N): if dataList[i][0] < dataList[j][0] and dataList[i][1] < dataList[j][1]: count += 1 print(count, end=" ") 2020. 11. 25. 이전 1 2 3 4 5 다음