Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c7197b8
BOJ 16235 나무 재테크 풀이(구현) - 박재환[JAVA]
ParkJaeHwan-906 Feb 2, 2026
1d62070
BOJ 18428 나무 재테크 풀이(구현) - 박재환[PYTHON]
ParkJaeHwan-906 Feb 2, 2026
caf5f29
CODETREE 여왕개미 풀이(이분탐색) - 박재환[JAVA]
ParkJaeHwan-906 Feb 2, 2026
360ea4c
CODETREE 여왕개미 최적화 풀이(이분탐색) - 박재환[JAVA]
ParkJaeHwan-906 Feb 2, 2026
8d4d6e2
SWAE 점심식사시간 풀이중
ParkJaeHwan-906 Feb 2, 2026
2f5c001
Merge remote-tracking branch 'origin/swea_점심식사시간' into hwannee
ParkJaeHwan-906 Feb 3, 2026
ceed800
BOJ 16236 아기상어 풀이(BFS) - 박재환
ParkJaeHwan-906 Feb 3, 2026
730f918
BOJ 16236 아기상어 풀이(BFS) - 박재환
ParkJaeHwan-906 Feb 3, 2026
64613ae
BOJ 19238 스타트 택시 풀이(BFS + 시뮬레이션) - 박재환
ParkJaeHwan-906 Feb 4, 2026
2bdeb9a
BOJ 19238 스타트 택시 풀이(BFS) - 박재환
ParkJaeHwan-906 Feb 4, 2026
9e6bd7c
CODETREE 해적 선장 코디 풀이(TreeSet + PQ + HASHMAP) - 박재환
ParkJaeHwan-906 Feb 4, 2026
ed2fc98
SWEA 미생물 격리 풀이(시뮬레이션) - 박재환
ParkJaeHwan-906 Feb 4, 2026
876c4c7
Merge branch 'hwannee' of https://github.com/ParkJaeHwan-906/Algorith…
ParkJaeHwan-906 Feb 4, 2026
06a763d
BOJ 12100 2048(Easy) 풀이(구현) - 박재환
ParkJaeHwan-906 Feb 5, 2026
34cb5dc
CODETREE AI로봇청소기 풀이(구현) - 박재환
ParkJaeHwan-906 Feb 5, 2026
d0d1ef2
SWEA 홈 방범 서비스 풀이 - 박재환
ParkJaeHwan-906 Feb 5, 2026
050c8a2
BOJ 2835 인기도 조사 풀이(누적합) - 박재환
ParkJaeHwan-906 Feb 6, 2026
27de7bd
BOJ 2835 인기도 조사 풀이(LAZY SegmentTree) - 박재환
ParkJaeHwan-906 Feb 6, 2026
338f026
BOJ 1113 수영장 만들기 풀이(BFS) - 박재환
ParkJaeHwan-906 Feb 6, 2026
14621d3
BOJ 1113 수영장 만들기 풀이(BFS) - 박재환
ParkJaeHwan-906 Feb 6, 2026
603c796
BOJ 16975 수열과 쿼리21 풀이(Lazy SegmentTree) - 박재환
ParkJaeHwan-906 Feb 6, 2026
6785706
BOJ 1507 궁금한 민호 풀이(플로이드워샬) - 박재환
ParkJaeHwan-906 Feb 7, 2026
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
194 changes: 194 additions & 0 deletions java/src/feb/week1/boj/easy2048_박재환.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
package feb.week1.boj;

import java.util.*;
import java.io.*;

public class easy2048_박재환 {
static BufferedReader br;
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
init();
br.close();
}
static StringTokenizer st;
static int n;
static void init() throws IOException {
n = Integer.parseInt(br.readLine().trim());
Block[][] map = new Block[n][n];
for(int x=0; x<n; x++) {
st = new StringTokenizer(br.readLine().trim());
for(int y=0; y<n; y++) {
int num = Integer.parseInt(st.nextToken());
if(num == 0) map[x][y] = null;
else map[x][y] = new Block(num);
}
}
int result = solution(map);
System.out.println(result);
}
static class Block {
int num;
boolean increase;

Block(int num) {
this.num = num;
}
}
/**
* 이동방향은 총 4가지 방향
* 상, 하, 좌, 우
* 5번 이동했을 때 최대
* 4 ** 5
*/
static int topValue;
static int solution(Block[][] map) {
topValue = 2;
moveBlock(0, map);
return topValue;
}
static int getTopValue(Block[][] map) {
int top = 0;
for(int x=0; x<n; x++) {
for(int y=0; y<n; y++) {
if(map[x][y] == null) continue;
top = Math.max(map[x][y].num, top);
}
}
return top;
}
static void moveBlock(int seq, Block[][] map) {
if(seq == 5) {
int top = getTopValue(map);
topValue = Math.max(top, topValue);
return;
}
/**
* 계속해서 map을 Copy 해서 새로운 map으로 생성
*/
for(int dir=0; dir<4; dir++) {
Block[][] copy = copyMap(map);
switch(dir) {
case 0:
left(copy);
break;
case 1:
right(copy);
break;
case 2:
top(copy);
break;
case 3:
bottom(copy);
break;
}
moveBlock(seq+1, copy);
}

}
static void left(Block[][] map) {
Deque<Block> q = new ArrayDeque<>();
for(int x=0; x<n; x++) {
q.clear();
for(int y=0; y<n; y++) {
if(map[x][y] == null) continue;
// 빈칸이 아닐 때
if(!q.isEmpty() && !q.getLast().increase && q.getLast().num == map[x][y].num) {
q.getLast().increase = true;
} else {
q.offer(map[x][y]);
}
}
for(int y=0; y<n; y++) {
if(!q.isEmpty()) {
Block block = q.poll();
if(block.increase) block.num *= 2;
map[x][y] = block;
} else {
map[x][y] = null;
}
}
}
}
static void right(Block[][] map) {
Deque<Block> q = new ArrayDeque<>();
for(int x=0; x<n; x++) {
q.clear();
for(int y=n-1; y>-1; y--) {
if(map[x][y] == null) continue;
// 빈칸이 아닐 때
if(!q.isEmpty() && !q.getLast().increase && q.getLast().num == map[x][y].num) {
q.getLast().increase = true;
} else {
q.offer(map[x][y]);
}
}
for(int y=n-1; y>-1; y--) {
if(!q.isEmpty()) {
Block block = q.poll();
if(block.increase) block.num *= 2;
map[x][y] = block;
} else {
map[x][y] = null;
}
}
}
}
static void top(Block[][] map) {
Deque<Block> q = new ArrayDeque<>();
for(int y=0; y<n; y++) {
q.clear();
for(int x=0; x<n; x++) {
if(map[x][y] == null) continue;
// 빈칸이 아닐 때
if(!q.isEmpty() && !q.getLast().increase && q.getLast().num == map[x][y].num) {
q.getLast().increase = true;
} else {
q.offer(map[x][y]);
}
}
for(int x=0; x<n; x++) {
if(!q.isEmpty()) {
Block block = q.poll();
if(block.increase) block.num *= 2;
map[x][y] = block;
} else {
map[x][y] = null;
}
}
}
}
static void bottom(Block[][] map) {
Deque<Block> q = new ArrayDeque<>();
for(int y=0; y<n; y++) {
q.clear();
for(int x=n-1; x>-1; x--) {
if(map[x][y] == null) continue;
// 빈칸이 아닐 때
if(!q.isEmpty() && !q.getLast().increase && q.getLast().num == map[x][y].num) {
q.getLast().increase = true;
} else {
q.offer(map[x][y]);
}
}
for(int x=n-1; x>-1; x--) {
if(!q.isEmpty()) {
Block block = q.poll();
if(block.increase) block.num *= 2;
map[x][y] = block;
} else {
map[x][y] = null;
}
}
}
}
static Block[][] copyMap(Block[][] map) {
Block[][] copy = new Block[n][n];
for(int x=0; x<n; x++) {
for(int y=0; y<n; y++) {
if(map[x][y] == null) copy[x][y] = null;
else copy[x][y] = new Block(map[x][y].num);
}
}
return copy;
}
}
55 changes: 55 additions & 0 deletions java/src/feb/week1/boj/궁금한민호_박재환.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package feb.week1.boj;

import java.util.*;
import java.io.*;

public class 궁금한민호_박재환 {
static BufferedReader br;
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
init();
br.close();
}
static StringTokenizer st;
static int n;
static int[][] map;
static void init() throws IOException {
n = Integer.parseInt(br.readLine().trim());
map = new int[n][n];
/**
* 주어지는 경로는 이미 최소거리
*/
for(int from=0; from<n; from++) {
st = new StringTokenizer(br.readLine().trim());
for(int to=0; to<n; to++) map[from][to] = Integer.parseInt(st.nextToken());
}
System.out.println(getMinCostAndMinRoad());
}
static int getMinCostAndMinRoad() {
boolean[][] unUsed = new boolean[n][n];
/**
* 플로이드 워셜을 이용해서 해당 거리가 최소 거리가 맞는지 검증
*/
for(int mid=0; mid<n; mid++) {
for(int from=0; from<n; from++) {
for(int to=0; to<n; to++) {
if(mid == from || mid == to || from == to) continue; // 실제 다른 도시와 연결된 간선만 비교대상으로 판단
if(map[from][to] > map[from][mid] + map[mid][to]) return -1; // 최소 경로가 아니였을 때
else if(map[from][to] == map[from][mid] + map[mid][to]) { // 동일한 비용의 경로가 존재한다면 -> 도로의 개수가 최소가 되어야하므로, 경유 도로 제거
unUsed[from][to] = true;
}
}
}
}
int sum = 0;
for(int from=0; from<n; from++) {
for(int to=0; to<n; to++) {
if(unUsed[from][to]) continue;
sum += map[from][to];
unUsed[from][to] = true;
unUsed[to][from] = true;
}
}
return sum;
}
}
Loading