[코드트리 물체 단위로 완전탐색] 삼각형 만들기 python
# n 입력 n = int(input()) # pos_list pos_list = list() # pos_list 입력 for _ in range(n): pos_list.append(tuple(map(int, input().split()))) # 함수들 # x_parallel(a, b, c): def x_parallel(a, b, c): # x1, y1 언팩킹 x1, y1 = pos_list[a] # x2, y2 언팩킹 x2, y2 = pos_list[b] # x3, y3 언팩킹 x3, y3 = pos_list[c] # 한 쌍이라도 y값이 같은 쌍이 있으면 통과 return y1 == y2 or y2 == y3 or y1 == y3 # y_parallel(a, b, c): def y_parallel(a,..
2022. 12. 15.
[코드트리 물체 단위로 완전탐색] 좌표평면 위의 특정 구역 2 python
# n 입력 n = int(input()) # pos_list pos_list = list() # pos_list 입력 for _ in range(n): pos_list.append(tuple(map(int, input().split()))) # 함수들 # calc(x, y) def calc(x, y): # max_x, min_x, max_y, min_y max_x, min_x = -sys.maxsize, sys.maxsize max_y, min_y = -sys.maxsize, sys.maxsize # 해당 좌표를 제외한 좌표를 탐색 for curr_x, curr_y in pos_list: # 해당 좌표라면 if curr_x == x and curr_y == y: # 스킵 continue # 아니라면 e..
2022. 12. 15.
[코드트리 자리 마다 숫자를 정하는 완전탐색] 개발팀의 능력 python
# ability_list 입력 ability_list = list(map(int, input().split())) # 함수들 # all_diff(a, b, c) def all_diff(a, b, c): # team_1, team_2 team_1, team_2 = ability_list[a] + ability_list[b], ability_list[c] # team_3 team_3 = sum(ability_list) - team_1 - team_2 # 서로 다른지 반환 return team_1 != team_2 and team_2 != team_3 and team_1 != team_3 # calc(a, b, c) def calc(a, b, c): # team_1, team_2 team_1, team_2 ..
2022. 12. 14.
[코드트리 자리 마다 숫자를 정하는 완전탐색] 개발자의 능력 2 python
파이썬 사용자는 참 축복받은 ㅋㅋㅋㅋ max, min 이런거 만들어주셔서 감사합니다. # ability_list 입력 ability_list = list(map(int, input().split())) # 함수들 # calc(a, b, c, d) def calc(a, b, c, d): # sum_1 sum_1 = ability_list[a] + ability_list[b] # sum_2 sum_2 = ability_list[c] + ability_list[d] # sum_3 sum_3 = sum(ability_list) - sum_1 - sum_2 # 반환 return max(sum_1, sum_2, sum_3) - min(sum_1, sum_2, sum_3) # 설계 # min_diff import s..
2022. 12. 13.
[코드트리 자리 마다 숫자를 정하는 완전탐색] 숫자 카운트 python
숫자야구를 파이썬으로 만들어볼줄이야,, 처음엔 당황했지만, 조건 하나씩 필터링해가며 비교해보면 될 듯 해서 만들어봤더니 돌아갔다. # n 입력 n = int(input()) # conditions conditions = [] # conditions 입력 for _ in range(n): num, cnt_1, cnt_2 = input().split() # 형 변환 cnt_1, cnt_2 = int(cnt_1), int(cnt_2) conditions.append([num, cnt_1, cnt_2]) # 함수들 # cnt_2_is_ok(k, correct_cnt, a, b, c) def cnt_2_is_ok(k, correct_cnt, a, b, c): # curr_cnt curr_cnt = 0 # k 분해..
2022. 12. 12.
[코드트리 자리 마다 숫자를 정하는 완전탐색] 두 가지로 열리는 자물쇠 python
원형에서 조건 따질때, 절댓값으로 해결하면 편하다는것을 기억하도록 하자는 교훈,,, # n 입력 n = int(input()) # comb_1 입력 comb_1 = list(map(int, input().split())) # comb_2 입력 comb_2 = list(map(int, input().split())) # 함수들 # open_with_comb_1(a, b, c) def open_with_comb_1(a, b, c): # a, b, c와 comb_1[0], comb_1[1], comb_1[2] 각각의 간격이 모두 2 이내이면 통과 return (abs(comb_1[0] - a) = n-2) and \ (abs(comb_1[1] - b) = n-2) and \ (abs(comb_1[2] - c)..
2022. 12. 12.
[코드트리 구간 단위로 완전탐색] 바구니 안의 사탕 2 python
문제에서 말하는게 너무 애매하다. 1. 바구니가 여러 개 들어갈 수 있다는 것이 동일선상의 여러 개 중 가장 큰 하나를 선택해야 한다는 것인지, 하나의 바구니로 합쳐진다는 것인지 알 수 없었다. 2. 앞 뒤 시작점이 모두 범위 내에 들어야 하는지 아닌지 명확하지 않다. # n, k 입력 n, k = map(int, input().split()) # linear linear = [0] * 401 # candy, pos 입력 for _ in range(n): candy, pos = map(int, input().split()) # linear에 추가 linear[pos] += candy # 함수들 # in_range(s, e) def in_range(s, e): # s가 양수이고, e가 400 이하면 통과 ..
2022. 12. 8.