https://www.acmicpc.net/problem/17069
9์ 30์ผ ํ์ด
https://www.acmicpc.net/problem/17070
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class b17069 {
static int N;
static int[][] graph;
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
N = Integer.parseInt(br.readLine());
graph = new int[N + 1][N + 1];
for(int i = 1; i < N + 1; i++) {
StringTokenizer st = new StringTokenizer(br.readLine());
for(int j = 1; j < N + 1; j++) {
graph[i][j] = Integer.parseInt(st.nextToken());
}
}
//๊ตฌํ
long[][][] dp = new long[N + 1][N + 1][3]; //0 : ๊ฐ๋ก, 1 : ์ธ๋ก, 2: ๋๊ฐ์
dp[1][2][0] = 1;
for(int i = 1; i <= N; i++) {
for(int j = 3; j <= N; j++) {
if(graph[i][j] != 1) {
dp[i][j][0] = dp[i][j - 1][0] + dp[i][j - 1][2];
dp[i][j][1] = dp[i - 1][j][1] + dp[i - 1][j][2];
if(graph[i - 1][j] != 1 && graph[i][j - 1] != 1) {
dp[i][j][2] = dp[i - 1][j - 1][0] + dp[i - 1][j - 1][1] + dp[i - 1][j - 1][2];
}
}
}
}
long answer = dp[N][N][0] + dp[N][N][1] + dp[N][N][2];
System.out.println(answer);
}
}
'Algorithm > ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ฐฑ์ค 1863๋ฒ : ์ค์นด์ด๋ผ์ธ ์ฌ์ด๊ฑฐ (0) | 2023.07.26 |
---|---|
๋ฐฑ์ค 23743๋ฒ : ๋ฐฉํ์ถ (0) | 2023.07.26 |
๋ฐฑ์ค 9205๋ฒ - ๋งฅ์ฃผ ๋ง์๋ฉด์ ๊ฑธ์ด๊ฐ๊ธฐ (0) | 2022.10.02 |
๋ฐฑ์ค 1189๋ฒ - ์ปด๋ฐฑํ (0) | 2022.10.01 |
๋ฐฑ์ค 18429๋ฒ - ๊ทผ์์ค (0) | 2022.08.28 |