목록문제 (388)
sm 기술 블로그
import java.util.*; import java.io.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuilder sb = new StringBuilder(); int N = sc.nextInt(); int[] board = new int[N]; for (int i = 0; i < N; i++) { board[i] = sc.nextInt(); } int M = sc.nextInt(); int[][] dp = new int[N][N]; // 필요한 조건 입력 완료 // dp 채우기 for (int i = 0; i < N; i++) { dp[i][i] = 1; } fo..
import sys input = sys.stdin.readline N = int(input()) board = list(input().split()) M = int(input()) dp = [[0]*N for _ in range(N)] result = [] for i in range(N): dp[i][i] = 1 for i in range(N-1): if board[i] == board[i+1]: dp[i][i+1] = 1 for i in range(2, N): for j in range(N-i): if board[j] == board[i+j] and dp[j+1][i+j-1] == 1: dp[j][i+j] = 1 for i in range(M): S, E = map(int, input().split(..
import java.util.*; import java.io.*; class Main { static int M; static int N; static int[][] dxdy = { { 1, 0 }, { -1, 0 }, { 0, -1 }, { 0, 1 } }; static int[][] dp; static int[][] travelMap; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] tmp = br.readLine().split(" "); M = Integer.parseInt(tmp[0]); N..
import sys sys.setrecursionlimit(10**8) input = sys.stdin.readline M, N = map(int, input().split()) travleMap = [list(map(int, input().split())) for _ in range(M)] dp = [[-1] * N for _ in range(M)] def dfs(x, y): # 도착지점 if x == M-1 and y == N-1: return 1 # -1이면 방문하지 않았다는 것임. if dp[x][y] == -1: # 목적지까지 갈 수 없는 경우는 0으로 반환 dp[x][y] = 0 # dx, dy 는 현재 기준 상하좌우 for dx, dy in (1, 0), (-1, 0), (0, -1), (0..