This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| # UTF-8 encoding when using korean | |
| from collections import deque | |
| M, N = map(int, input().split()) | |
| maps = [] | |
| start = [] | |
| for y in range(N): | |
| temp = list(map(int, input().split())) | |
| for x in range(M): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| # UTF-8 encoding when using korean | |
| import sys | |
| import heapq | |
| from collections import defaultdict | |
| n = int(sys.stdin.readline()) | |
| work_list = [list(map(int,sys.stdin.readline().replace("\n","").split())) for _ in range(n)] | |
| # 날짜 순 오름차순 정렬 | |
| # ex) 현재가 7일이면, 마감일이 6일 이전인 일들을 작업할 수 없다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| # UTF-8 encoding when using korean | |
| import sys | |
| N = int(sys.stdin.readline()) | |
| M = int(sys.stdin.readline()) | |
| arr = [0 for _ in range(N+1)] | |
| for _ in range(M): | |
| idx = int(sys.stdin.readline()) | |
| arr[idx] = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import heapq | |
| from collections import defaultdict | |
| def solve(precede_list, build_next, time, target): | |
| # 조건 없이 바로 만들 수 있는 건물들 찾기 | |
| queue = [(time[idx], idx) for idx in range(1, len(precede_list)) if precede_list[idx] == 0] | |
| # 시간순서로 정렬. 가장 시간 짧은 것부터 뽑아내는 min heap 사용 | |
| heapq.heapify(queue) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import heapq | |
| import sys | |
| # 중앙값 기준으로 작은 값 = left, 큰 값 = right | |
| left, right = [], [] | |
| n = int(sys.stdin.readline()) | |
| for _ in range(n): | |
| num = int(sys.stdin.readline()) | |
| if len(left) == len(right): | |
| # max_heap. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/python3 | |
| import math | |
| import os | |
| import random | |
| import re | |
| import sys | |
| # Complete the climbingLeaderboard function below. | |
| def climbingLeaderboard(scores, alice): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/python3 | |
| import math | |
| import os | |
| import random | |
| import re | |
| import sys | |
| from collections import Counter | |
| # Complete the isValid function below. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/python3 | |
| import math | |
| import os | |
| import random | |
| import re | |
| import sys | |
| # Complete the bigSorting function below. | |
| def bigSorting(unsorted): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/python3 | |
| import math | |
| import os | |
| import random | |
| import re | |
| import sys | |
| from collections import deque, defaultdict | |
| # Complete the findShortest function below. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from itertools import chain | |
| # 2d Array에서 네 개의 문자열이 사각형 모양으로 일치할 경우를 파악하기 | |
| def find_square(maps): | |
| table = [[0 for _ in range(len(maps))] for _ in range(len(maps))] | |
| for y in range(1, len(maps)): | |
| for x in range(1, len(maps)): | |
| if maps[y-1][x-1] == maps[y-1][x] == maps[y][x-1] == maps[y][x] and maps[y][x] != "#": | |
| table[y-1][x-1] += 1 | |
| table[y-1][x] += 1 | |
| table[y][x-1] += 1 |