Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions week39/강성욱/baekjoon/A와_B.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package week39.강성욱.baekjoon;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
* PackageName : week39.강성욱.baekjoon
* FileName : A와_B
* Author : Baekgwa
* Date : 26. 1. 30.
* Description :
* =====================================================================================================================
* DATE AUTHOR NOTE
* ---------------------------------------------------------------------------------------------------------------------
* 26. 1. 30. Baekgwa Initial creation
*/
public class A와_B {
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String start = br.readLine();
String end = br.readLine();

while(true) {
if(end.length() < start.length()) {
System.out.println(0);
return;
}

String lastChar = end.substring(end.length()-1, end.length());
end = end.substring(0, end.length()-1);

// B 였으면, B 빼고 뒤집기
if(lastChar.equals("B")) {
end = reverseEnd(end);
}

if(end.equals(start)) {
System.out.println(1);
return;
}
}
}

private static String reverseEnd(String end) {
StringBuilder sb = new StringBuilder();
for(int i=end.length()-1;i>=0;i--) {
sb.append(end.charAt(i));
}
return sb.toString();
}
}
}
72 changes: 72 additions & 0 deletions week39/강성욱/baekjoon/내리막_길.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package week39.강성욱.baekjoon;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
* PackageName : week39.강성욱.baekjoon
* FileName : 내리막_길
* Author : Baekgwa
* Date : 26. 1. 30.
* Description :
* =====================================================================================================================
* DATE AUTHOR NOTE
* ---------------------------------------------------------------------------------------------------------------------
* 26. 1. 30. Baekgwa Initial creation
*/
public class 내리막_길 {
public class Main {

private static int M, N;
private static int[][] map;
private static int[][] dp;
private static final int[] dy = {0, -1, 0, 1};
private static final int[] dx = {-1, 0, 1, 0};

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());

M = Integer.parseInt(st.nextToken());
N = Integer.parseInt(st.nextToken());

map = new int[M][N];
dp = new int[M][N];

for (int i = 0; i < M; i++) {
st = new StringTokenizer(br.readLine());
for (int j = 0; j < N; j++) {
map[i][j] = Integer.parseInt(st.nextToken());
dp[i][j] = -1;
}
}

System.out.println(dfs(0, 0));
}

static int dfs(int y, int x) {
if (y == M - 1 && x == N - 1) {
return 1;
}

if (dp[y][x] != -1) {
return dp[y][x];
}

dp[y][x] = 0;
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];

if(ny < 0 || ny >= M || nx < 0 || nx >= N) continue;
if(map[y][x] <= map[ny][nx]) continue;

dp[y][x] += dfs(ny, nx);
}

return dp[y][x];
}
}
}