Candidate | Softeer Assessment UI
Candidate | Softeer Assessment UI
softeer.ai
나의 코드
import sys
from itertools import permutations
input = sys.stdin.readline
line_num = int(input())
max_group_sum=0
map_list = []
for _ in range(line_num):
map_list.append(list(map(int,input().split())))
#print(map_list)
def check_and_cl(permu_list):
answer=0
first_len = len(permu_list)*2
check_set = set()
for i in permu_list:
for j in i:
answer+=map_list[j[0]][j[1]]
check_set.add(j)
if len(check_set)==first_len:
return answer
else:
return 0
use_index = []
for i in range(len(map_list)):
for j in range(len(map_list[0])):
if i==(line_num-1) and j!=(line_num-1):
use_index.append([(i,j),(i,j+1)])
elif j==(line_num-1) and i!=(line_num-1):
use_index.append([(i,j),(i+1,j)])
elif i!=(line_num-1) and j!=(line_num-1):
use_index.append([(i,j),(i,j+1)])
use_index.append([(i,j),(i+1,j)])
#print(use_index)
for com_n in range(4,0,-1):
for permu in permutations(use_index, com_n):
max_group_sum = max(max_group_sum, check_and_cl(permu))
if max_group_sum:
break
print(max_group_sum)'코딩테스트 파이썬 > Softeer' 카테고리의 다른 글
| Softeer 연습문제(3단계) - 플레이페어 암호 (1) | 2024.06.28 |
|---|---|
| Softeer 연습문제(3단계) - 순서대로 방문하기 (0) | 2024.06.28 |
| Softeer 연습문제(3단계) - 징검다리 (0) | 2024.06.27 |
| Softeer 연습문제(2단계) - 회의실 예약 (0) | 2024.06.26 |
| Softeer 연습문제(2단계) - 지도 자동 구축 (0) | 2024.06.26 |