Skip to content

Commit

Permalink
Merge branch 'main' into 6-Me-in-U
Browse files Browse the repository at this point in the history
  • Loading branch information
Me-in-U authored Jun 6, 2024
2 parents b7a1af6 + e27ea97 commit 7e0026b
Show file tree
Hide file tree
Showing 9 changed files with 329 additions and 7 deletions.
2 changes: 1 addition & 1 deletion BOJ-ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
| 3μ°¨μ‹œ | 2024.03.26 | νŽœμœ…νŠΈλ¦¬ | [ꡬ간 ν•© κ΅¬ν•˜κΈ°](https://www.acmicpc.net/problem/2042) | [#13](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pulls/13) |
| 4μ°¨μ‹œ | 2024.03.30 | 볼둝껍질 | [볼둝 껍질](https://www.acmicpc.net/problem/1708) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pulls/14) |
| 5μ°¨μ‹œ | 2024.04.29 | μŠ€μœ„ν•‘ | [μ—¬λŸ¬ μ§μ‚¬κ°ν˜•μ˜ 전체 면적 κ΅¬ν•˜κΈ°](https://www.acmicpc.net/problem/2672) | [#19](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pulls/19) |
| 6μ°¨μ‹œ | 2024.05.13 | μœ„μƒμ •λ ¬ | [쀄 μ„Έμš°κΈ°](https://www.acmicpc.net/problem/2252) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pulls/20) |
| 6μ°¨μ‹œ | 2024.05.13 | μœ„μƒμ •λ ¬ | [쀄 μ„Έμš°κΈ°](https://www.acmicpc.net/problem/2252) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pulls/20) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.StringTokenizer;

public class Main {
static class RectangleEvent implements Comparable<RectangleEvent> {
int x;
int yUp;
int yDown;
int chk;

public RectangleEvent(int x, int yDown, int yUp, int chk) {
this.x = x;
this.yUp = yUp;
this.yDown = yDown;
this.chk = chk;
}

@Override
public int compareTo(RectangleEvent o) {
if (this.x == o.x)
return this.chk - o.chk;
return this.x - o.x;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
RectangleEvent that = (RectangleEvent) obj;
return this.x == that.x && this.yUp == that.yUp && this.yDown == that.yDown && this.chk == that.chk;
}

@Override
public int hashCode() {
return Objects.hash(x, yUp, yDown, chk);
}
}

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = null;
int n = Integer.parseInt(br.readLine());
List<RectangleEvent> events = new ArrayList<>();
int[] sweep = new int[20001];
while (n-- > 0) {
st = new StringTokenizer(br.readLine());
int xStart = (int) (Double.parseDouble(st.nextToken()) * 10);
int yDown = (int) (Double.parseDouble(st.nextToken()) * 10);
int xEnd = xStart + (int) (Double.parseDouble(st.nextToken()) * 10);
int height = (int) (Double.parseDouble(st.nextToken()) * 10);
int yUp = yDown + height;
events.add(new RectangleEvent(xStart, yDown, yUp, 1));
events.add(new RectangleEvent(xEnd, yDown, yUp, -1));
}
Collections.sort(events);
int area = 0;
int x = 0;
for (RectangleEvent event : events) {
int count = 0;
for (int i = 0; i < 20001; i++)
if (sweep[i] > 0)
count++;
area += count * (event.x - x);
for (int i = event.yDown; i < event.yUp; i++) {
if (event.chk == 1)
sweep[i]++;
else
sweep[i]--;
}
x = event.x;
}
System.out.println(area % 100 == 0 ? (int) (area * 0.01) : String.format("%.2f", area * 0.01));
}
}
9 changes: 5 additions & 4 deletions SunYerim/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## ✏️ 기둝

| μ°¨μ‹œ | λ‚ μ§œ | λ¬Έμ œμœ ν˜• | 링크 | 풀이 |
|:---:|:----------:|:----:|:-----------------------------------------------:|:--------------------------------------------------------:|
| μ°¨μ‹œ | λ‚ μ§œ | λ¬Έμ œμœ ν˜• | 링크 | 풀이 |
|:---:|:----------:|:----:|:---------------------------------------------------:|:--------------------------------------------------------:|
| 1μ°¨μ‹œ | 2024.03.18 | κ΅¬ν˜„ | [이차원 λ°°μ—΄κ³Ό μ—°μ‚°](https://www.acmicpc.net/problem/17140) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/5) |
| 2μ°¨μ‹œ | 2024.03.22 | μŠ€νƒ | [ν‚€λ‘œκ±°](https://www.acmicpc.net/problem/5397) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/7) |
| 3μ°¨μ‹œ | 2024.03.26 | DP | [μ•±](https://www.acmicpc.net/problem/7579) | [#3](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/11) |
| 2μ°¨μ‹œ | 2024.03.22 | μŠ€νƒ | [ν‚€λ‘œκ±°](https://www.acmicpc.net/problem/5397) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/7) |
| 3μ°¨μ‹œ | 2024.03.26 | DP | [μ•±](https://www.acmicpc.net/problem/7579) | [#3](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/11) |
| 4μ°¨μ‹œ | 2024.03.30 | κ·Έλž˜ν”„ | [νƒˆμΆœ](https://www.acmicpc.net/problem/3055) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/16) |
123 changes: 123 additions & 0 deletions SunYerim/κ·Έλž˜ν”„/BOJ3055.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Queue;
import java.util.StringTokenizer;

public class BOJ3055 {
static int r, c;
static int startX, startY, endX, endY;
static char[][] map;
static boolean[][] visited;
static boolean[][] waterVisited;
static int[] dx = {1, -1, 0, 0};
static int[] dy = {0, 0, -1, 1};
static ArrayDeque<Node> water;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
r = Integer.parseInt(st.nextToken());
c = Integer.parseInt(st.nextToken());
map = new char[r][c];
visited = new boolean[r][c];
waterVisited = new boolean[r][c];
water = new ArrayDeque<Node>();

for (int i = 0; i < r; i++) {
String tmp = br.readLine();
for (int j = 0; j < c; j++) {
map[i][j] = tmp.charAt(j);
if (map[i][j] == 'S') {
startX = i;
startY = j;
} else if (map[i][j] == 'D') {
endX = i;
endY = j;
} else if (map[i][j] == '*') {
water.add(new Node(i, j, 0));
}
}
}

bfs(startX, startY);
}

private static void bfs(int x, int y) {
Queue<Node> queue = new ArrayDeque<>(); // 두더지가 κ°€λŠ” 경둜만 λ‹΄λŠ”λ‹€
queue.add(new Node(x, y, 0)); // μΆœλ°œμ§€μ  λ„£κ³ 
visited[x][y] = true;

while (!queue.isEmpty()) {
// 물을 퍼뜨린 ν›„ κ³ μŠ΄λ„μΉ˜ 이동 -> κ³ μŠ΄λ„μΉ˜λ„ 물은 톡과 λͺ»ν•œλ‹€.
int size = queue.size();
for (int s = 0; s < size; s++) {
Node curr = queue.poll();
int currX = curr.x;
int currY = curr.y;
int currCnt = curr.count;
if (map[currX][currY] == '*')
continue;

// κΈ°μ €
if (map[currX][currY] == 'D') {
System.out.println(currCnt);
return;
}
for (int i = 0; i < 4; i++) {
int nx = dx[i] + currX;
int ny = dy[i] + currY;
if (nx >= 0 && ny >= 0 && nx < r && ny < c && !visited[nx][ny]) {
// κ³ μŠ΄λ„μΉ˜κ°€ κ°€λ €λŠ” μžλ¦¬μ— λ¬Όμ΄λ‚˜ 돌이 있으면
if (map[nx][ny] == '*' || map[nx][ny] == 'X') continue;
visited[nx][ny] = true;

queue.add(new Node(nx, ny, currCnt+1));

}
}

}
// μš°μ„  λ¬ΌλΆ€ν„° νΌλœ¨λ¦°λ‹€. -> 물은 돌과 μ†Œκ΅΄μ΄ μžˆλŠ” 자리, Dλ‘œλŠ” 퍼질 수 μ—†λ‹€.
int waterSize = water.size();
for (int i = 0; i < waterSize; i++) {
Node waters = water.poll();
int waterX = waters.x;
int waterY = waters.y;
//int waterCnt = waters.count;
// κ°€λ €λŠ” 곳이 돌이 μ•„λ‹ˆκ³  λΉ„λ²„μ˜ ꡴이 μ•„λ‹λ•Œ
for (int j = 0; j < 4; j++) {
int nx = dx[j] + waterX;
int ny = dy[j] + waterY;
if (nx >= 0 && ny >= 0 && nx < r && ny < c) {
// λŒμ΄μ•„λ‹ˆκ³  ꡴이 μ•„λ‹ˆμ—¬μ•Όν•¨
if (map[nx][ny] == 'X' || map[nx][ny] == 'D' || waterVisited[nx][ny]) continue;
// 갈 수 μžˆλŠ” 곳이라면

map[nx][ny] = '*';
waterVisited[nx][ny] = true;
water.add(new Node(nx, ny, 0));


}
}
}
}

System.out.println("KAKTUS");




}

static class Node {
private int x, y, count;
public Node (int x, int y, int count) {
this.x = x;
this.y = y;
this.count = count;
}
}
}
38 changes: 38 additions & 0 deletions erase-jeong/BFS/BOJ2178_λ―Έλ‘œνƒμƒ‰.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from collections import deque

N, M = map(int, input().split())

graph = []

for _ in range(N):
graph.append(list(map(int, input())))

def BFS(x, y):
# 이동할 상, ν•˜, 쒌, 우 λ°©ν–₯ μ •μ˜
dx = [-1,1,0,0]
dy = [0,0,-1,1]

queue = deque()
queue.append((x,y))

while queue:
x, y = queue.popleft()

for i in range(4):
nx = x + dx[i]
ny = y + dy[i]

if nx<0 or nx>=N or ny<0 or ny>=M:
continue

if graph[nx][ny]==0:
continue

if graph[nx][ny]==1:
graph[nx][ny] = graph[x][y]+1
queue.append((nx,ny))


return graph[N-1][M-1]

print(BFS(0,0))
35 changes: 35 additions & 0 deletions erase-jeong/DFS_BFS/μ΄Œμˆ˜κ³„μ‚°.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#μž…λ ₯κ°’ λ°›λŠ” λΆ€λΆ„
n=int(input())
a,b=map(int,input().split())
m=int(input())

#κΈ°λ³Έ μ„ μ–Έ
graph=[[] for _ in range(n+1)] #λ…Έλ“œμ˜ λ²ˆν˜Έμ™€ λ°°μ—΄ 번호 ν†΅μΌμ‹œν‚€κΈ° μœ„ν•΄μ„œ n이 μ•„λ‹Œ n+1 μ‚¬μš©
visited=[[False]*(n+1)]
result=[]


for _ in range(m):
x,y=map(int, input().split())
graph[x].append(y)
graph[y].append(x)



def dfs(v,num):
num+=1
visited[v]=True

if v==b:
result.append(num)

for i in graph[v]:
if not visited[i]:
dfs(i,num)

dfs(a,0)

if len(result)==0:
print(-1)
else:
print(result)
6 changes: 4 additions & 2 deletions erase-jeong/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

| μ°¨μ‹œ | λ‚ μ§œ | λ¬Έμ œμœ ν˜• | 링크 | 풀이 |
|:----:|:---------:|:----:|:-----:|:----:|
| 1μ°¨μ‹œ | 2024.03.18 | 그리디 | [ꡬλͺ…λ³΄νŠΈ](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/4) |
---
| 1μ°¨μ‹œ | 2023.03.18 | 그리디 | [ꡬλͺ…λ³΄νŠΈ](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/4)|
| 2μ°¨μ‹œ | 2023.03.23 | DFS/BFS | [μ΄Œμˆ˜κ³„μ‚°](https://www.acmicpc.net/problem/2644) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/8)|
| 3μ°¨μ‹œ | 2023.03.28 | DP | [ν‰λ²”ν•œ λ°°λ‚­](https://www.acmicpc.net/problem/12865) | [#3](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/12)|
| 4μ°¨μ‹œ | 2023.03.28 | DP | [미둜 탐색](https://www.acmicpc.net/problem/2178) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/17)|
1 change: 1 addition & 0 deletions wjdheesp44/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
| 1μ°¨μ‹œ | 2024.03.18 | κ΅¬ν˜„ | [μ£Όμ‚¬μœ„ ꡴리기](https://www.acmicpc.net/problem/14499) | [#3](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/3) |
| 2μ°¨μ‹œ | 2024.03.22 | κ΅¬ν˜„ | [λ±€](https://www.acmicpc.net/problem/3190) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/6) |
| 3μ°¨μ‹œ | 2024.03.26 | λ°±νŠΈλž˜ν‚Ή | [μ—°μ‚°μž λΌμ›Œλ„£κΈ°](https://www.acmicpc.net/problem/14888) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/10) |
| 4μ°¨μ‹œ | 2024.03.30 | bfs | [μ•ˆμ „ μ˜μ—­](https://www.acmicpc.net/problem/2468) | [#15](https://github.com/AlgoLeadMe/AlgoLeadMe-9/pull/15) |
---
38 changes: 38 additions & 0 deletions wjdheesp44/bfs/2468_μ•ˆμ „ μ˜μ—­.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import sys
from collections import deque
input = sys.stdin.readline

sum = 0
cnt = 0
n = int(input())
max_height = 0
board = [list(map(int, input().split())) for _ in range(n)]

max_height = max(map(max, board))

def bfs(x, y, k):
dx, dy = [-1, 0, 1, 0], [0, 1, 0, -1]
q = deque()
q.append((x, y))

while q:
x, y = q.popleft()
for i in range(4):
nx, ny = x + dx[i], y + dy[i]
if 0 <= nx < n and 0 <= ny < n and visited[nx][ny] == 0 and board[nx][ny] > k:
visited[nx][ny] = 1
q.append((nx, ny))


for k in range(max_height):
visited = [[0] * n for _ in range(n)]
cnt = 0

for i in range(n):
for j in range(n):
if visited[i][j] == 0 and board[i][j] > k:
bfs(i, j, k)
cnt += 1
sum = max(sum, cnt)

print(sum)

0 comments on commit 7e0026b

Please sign in to comment.