본문 바로가기

Algorithm/etc111

[자바] SWEA 1949 : 등산로 조성 (test) [자바] SWEA 1949 : 등산로 조성 (test)SWEA 1949 : 등산로 조성풀이방향성 생각시작점에서 DFS 돌리기높이를 깎을 땐, 최소한만 깎아야 등산로를 최대한 길게 탐색할 수 있다. 전체코드import java.io.*;import java.util.*;public class Solution { static int N, K, maxHeight, answer; static int[][] arr; static boolean[][] V; static List starts; static int[][] dires = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; public static boolean inside(int x, int y) { .. 2025. 4. 5.
[파이썬] 백준 14888 : 연산자 끼워넣기 (실버1) [파이썬] 백준 14888 : 연산자 끼워넣기 (실버1)https://www.acmicpc.net/problem/14888풀이방향성 생각dfs 완탐 전체코드N = int(input())arr = list(map(int,input().split()))ops = list(map(int,input().split()))answer = [-float('inf'),float('inf')]def dfs(cnt,val): if cnt == N: answer[0] = max(answer[0],val) answer[1] = min(answer[1],val) for idx,op in enumerate(ops): if op: ops[idx] -= 1 .. 2025. 4. 5.
[파이썬] 백준 14889 : 스타트와 링크 (실버1) [파이썬] 백준 14889 : 스타트와 링크 (실버1)https://www.acmicpc.net/problem/14889풀이방향성 생각combination -> gospers hack 전체코드N = int(input())R = N//2arr = [list(map(int,input().split())) for _ in range(N)]answer = float('inf')x = (1> 1) - 1print(answer)코멘트두 그룹으로 분할하는 경우에는 확실히 next comb를 gospers hack으로 구현하는게 쉽다. 2025. 4. 5.
[파이썬] 백준 1182 : 부분수열의 합 (실버2) [파이썬] 백준 1182 : 부분수열의 합 (실버2)https://www.acmicpc.net/problem/1182풀이방향성 생각2^20까지라 그냥 완탐가능해서 완탐으로 풀이. 전체코드N,target = map(int,input().split())arr = list(map(int,input().split()))answer = 0for comb in range(1,1코멘트. 2025. 3. 31.