Skip to content

Commit

Permalink
Merge branch 'main' into 12-pu2rile
Browse files Browse the repository at this point in the history
  • Loading branch information
pu2rile committed Sep 4, 2024
2 parents 7d09f32 + 3531374 commit 56dc49e
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 6 deletions.
5 changes: 3 additions & 2 deletions oesnuj/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
| 2μ°¨μ‹œ | 2024.03.29 | μ—°κ²°λ¦¬μŠ€νŠΈ | [에디터](https://www.acmicpc.net/problem/1406) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/8) |
| 3μ°¨μ‹œ | 2024.04.02 | 덱 | [μΉ΄λ“œ 놓기](https://www.acmicpc.net/problem/18115) | [#11](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/11) |
| 4μ°¨μ‹œ | 2024.04.06 | μŠ€νƒ | [μ˜₯상 정원 κΎΈλ―ΈκΈ°](https://www.acmicpc.net/problem/6198) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/14) |
| 5μ°¨μ‹œ | 2024.04.13 | 이뢄탐색 | [λ“£λ³΄μž‘](https://www.acmicpc.net/problem/1764) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/20) |
| 6μ°¨μ‹œ | 2024.05.06 | κΈ°ν•˜ν•™ | [μ •μ‚¬κ°ν˜•](https://www.acmicpc.net/problem/1485) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/22) |
| 5μ°¨μ‹œ | 2024.04.13 | 이뢄 탐색 | [λ“£λ³΄μž‘](https://www.acmicpc.net/problem/1764) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/20) |
| 6μ°¨μ‹œ | 2024.05.06 | κΈ°ν•˜ | [μ •μ‚¬κ°ν˜•](https://www.acmicpc.net/problem/1485) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/22) |
| 7μ°¨μ‹œ | 2024.05.08 | μŠ€νƒ, 큐, 덱 | [queuestack](https://www.acmicpc.net/problem/24511) | [#24](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/24) |
| 8μ°¨μ‹œ | 2024.05.13 | μš°μ„ μˆœμœ„ 큐 | [μΉ΄λ“œ μ •λ ¬ν•˜κΈ°](https://www.acmicpc.net/problem/1715) | [#27](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/27) |
| 9μ°¨μ‹œ | 2024.05.30 | κ΅¬ν˜„ | [λΉ™κ³ ](https://www.acmicpc.net/problem/2578) | [#30](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/30) |
| 10μ°¨μ‹œ | 2024.07.04 | κ΅¬ν˜„ | [μƒμ–΄μ΄ˆλ“±ν•™κ΅](https://www.acmicpc.net/problem/21608) | [#34](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/34) |
| 11μ°¨μ‹œ | 2024.07.18 | 이뢄 탐색 | [λžœμ„  자λ₯΄κΈ°](https://www.acmicpc.net/problem/1654) | [#38](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/38) |
---
2 changes: 0 additions & 2 deletions oesnuj/κ΅¬ν˜„/21608.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,3 @@ function calcSatisfy(){
}
}
return result;
}
좜처: https://oesnuj.tistory.com/entry/Nodejs-λ°±μ€€-Javascript-21608-상어-μ΄ˆλ“±ν•™κ΅ [λΉ„νŠΈλ‘œ κ·Έλ¦¬λŠ” μ„±μž₯일기:ν‹°μŠ€ν† λ¦¬]
35 changes: 35 additions & 0 deletions oesnuj/이뢄 탐색/1654.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>
#include <vector>
using namespace std;

bool check(vector <int>& v, int n, long long length);
int binary_serach(vector <int>& v, int n);

int main() {
int k, n;
cin >> k >> n;
vector <int> v(k);
for (auto& i : v) {
cin >> i;
}
cout << binary_serach(v, n);
return 0;
}

bool check(vector <int>& v, int n, long long length) {
int cnt = 0;
for (const auto& i : v) {
cnt += i / length;
}
return cnt >= n;
}

int binary_serach(vector <int>& v, int n) {
long long lo = 1, hi = 2147483648; //자λ₯Ό 수 μžˆλŠ” λžœμ„ μ˜ λ²”μœ„
while (lo + 1 < hi) {
long long mid = (lo + hi) / 2;
if (check(v, n, mid)) lo = mid;
else hi = mid;
}
return lo;
}
File renamed without changes.
Binary file modified pu2rile/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion pu2rile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
| 9μ°¨μ‹œ | 2024.05.27 | κ΅¬ν˜„ | [μ˜€λŠ˜λ„ μ‘Œλ‹€](https://www.acmicpc.net/problem/14582) | [#29](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/29#issue-2320060288)
| 10μ°¨μ‹œ | 2024.07.11 | μŠ€νƒ | [ν™”ν•™μ‹λŸ‰](https://www.acmicpc.net/problem/2257) | [#35](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/35#issue-2403173169)
| 11μ°¨μ‹œ | 2024.07.13 | μš°μ„ μˆœμœ„ 큐 | [κ°•μ˜μ‹€](https://www.acmicpc.net/problem/1374) | [#37](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/37#issue-2406937336)
| 12μ°¨μ‹œ | 2024.07.23 | 동적 ν”„λ‘œκ·Έλž˜λ° | [1ν•™λ…„](https://www.acmicpc.net/problem/5557) | [#40](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/40)
| 12μ°¨μ‹œ | 2024.07.23 | 동적 ν”„λ‘œκ·Έλž˜λ° | [1ν•™λ…„](https://www.acmicpc.net/problem/5557) | [#40](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/40)
25 changes: 25 additions & 0 deletions pu2rile/μš°μ„ μˆœμœ„ 큐/κ°•μ˜μ‹€.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import heapq
import sys

n = int(sys.stdin.readline())

heap = [] # λͺ¨λ“  κ°•μ˜μ˜ μ‹œμž‘ μ‹œκ°„κ³Ό μ’…λ£Œ μ‹œκ°„μ„ μ €μž₯ν•  μ΅œμ†Œ νž™
q = [] # ν˜„μž¬ μ‚¬μš© 쀑인 κ°•μ˜μ‹€μ˜ μ’…λ£Œ μ‹œκ°„μ„ μ €μž₯ν•  μ΅œμ†Œ νž™

# 주어진 κ°•μ˜ 수만큼 λ°˜λ³΅ν•˜λ©΄μ„œ κ°•μ˜ 정보λ₯Ό μž…λ ₯λ°›μ•„ μ΅œμ†Œ νž™μ— μ €μž₯
for _ in range(n):
num, start, end = map(int, sys.stdin.readline().split())
heapq.heappush(heap, [start, end, num])

# 첫 번째 κ°•μ˜λ₯Ό μ΅œμ†Œ νž™μ—μ„œ κΊΌλ‚΄μ„œ ν•΄λ‹Ή κ°•μ˜μ˜ μ’…λ£Œ μ‹œκ°„μ„ λ‹€λ₯Έ νž™μ— μ €μž₯
start, end, num = heapq.heappop(heap)
heapq.heappush(q, end)

while heap:
start, end, num = heapq.heappop(heap)
# κ°€μž₯ 빨리 λλ‚˜λŠ” κ°•μ˜μ‹€μ˜ μ’…λ£Œ μ‹œκ°„μ΄ ν˜„μž¬ κ°•μ˜μ˜ μ‹œμž‘ μ‹œκ°„λ³΄λ‹€ μž‘κ±°λ‚˜ κ°™μœΌλ©΄ μ’…λ£Œ μ‹œκ°„μ„ μ΅œμ†Œ νž™μ—μ„œ 제거
if q[0] <= start:
heapq.heappop(q)
heapq.heappush(q, end) # ν˜„μž¬ κ°•μ˜μ˜ μ’…λ£Œ μ‹œκ°„μ„ μ΅œμ†Œ νž™μ— μΆ”κ°€

print(len(q)) # μ΅œμ†Œ νž™ q의 크기가 ν•„μš”ν•œ κ°•μ˜μ‹€μ˜ 수
4 changes: 3 additions & 1 deletion suhyun113/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
| 6μ°¨μ‹œ | 2024.04.14 | μŠ€νƒ | [컨트둀 제트](https://school.programmers.co.kr/learn/courses/30/lessons/120853) | [#21](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/21) |
| 7μ°¨μ‹œ | 2024.05.09 | 트리 | [μ›μˆ­μ΄ 맀달기](https://www.acmicpc.net/problem/2716) | [#31](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/31) |
| 8μ°¨μ‹œ | 2024.05.14 | μˆ˜ν•™ | [μ–΄λ¦° μ™•μž](https://www.acmicpc.net/problem/1004) | [#32](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/32) |
| 9μ°¨μ‹œ | 2024.05.28 | λ‹€μ΅μŠ€νŠΈλΌ | [μ΅œμ†ŒλΉ„μš© κ΅¬ν•˜κΈ°](https://www.acmicpc.net/problem/1916) | [#33](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/33) |
| 9μ°¨μ‹œ | 2024.05.28 | λ‹€μ΅μŠ€νŠΈλΌ | [μ΅œμ†ŒλΉ„μš© κ΅¬ν•˜κΈ°](https://www.acmicpc.net/problem/1916) | [#33](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/33) |
| 10μ°¨μ‹œ | 2024.07.13 | ν”Œλ‘œμ΄λ“œ-μ›Œμ…œ | [ν”Œλ‘œμ΄λ“œ](https://www.acmicpc.net/problem/11404) | [#36](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/36) |
| 11μ°¨μ‹œ | 2024.07.16 | BFS | [μ—°κ΅¬μ†Œ](https://www.acmicpc.net/problem/14502) | [#39](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/39) |
106 changes: 106 additions & 0 deletions suhyun113/κ΅¬ν˜„/11-suhyun113.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
//14502 : μ—°κ΅¬μ†Œ

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

// λ©”ν¬λ‘œ μ„€μ •
#define BLANK 0
#define WALL 1
#define VIRUS 2

int N, M; // μ§€λ„μ˜ μ„Έλ‘œ 크기, κ°€λ‘œ 크기
vector<vector<int>> initial_map; // 초기 지도
vector<pair<int, int>> blank_map; // 빈 칸
int directions[4][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} }; // λ°©ν–₯

// κ°€λŠ₯ν•œ λͺ¨λ“  λ²½ μ„Έμš°κΈ° μ‘°ν•© κ΅¬ν•˜κΈ°
vector<vector<pair<int, int>>> building_walls() {
vector<vector<pair<int, int>>> combinations;
int size = blank_map.size(); // 빈 칸 크기
for (int i = 0; i < size; i++) {
for (int j = i + 1; j < size; j++) {
for (int k = j + 1; k < size; k++) {
// 빈 칸에 λ²½ 3개 μ„Έμš°κΈ°
combinations.push_back({blank_map[i], blank_map[j], blank_map[k]});
}
}
}
return combinations;
}

// λ„ˆλΉ„ μš°μ„  탐색(λ°”μ΄λŸ¬μŠ€μΈ μΉΈ 큐에 μ €μž₯ ν›„,
// λ°”μ΄λŸ¬μŠ€ μΉΈ μ£Όλ³€ 칸이 λ°”μ΄λŸ¬μŠ€ μ•„λ‹Œ 빈 칸이라면,
// μ£Όλ³€ 칸을 λ°”μ΄λŸ¬μŠ€λ‘œ λ°”κΎΈκΈ°)
void bfs(vector<vector<int>>& map_copy) {
queue<pair<int, int>> q;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
if (map_copy[i][j] == VIRUS) {
q.push({i, j});
}
}
}
// λ°”μ΄λŸ¬μŠ€μΈ 칸이 μ•„λ‹ˆκ³  빈 칸이라면,
while (!q.empty()) {
int x = q.front().first;
int y = q.front().second;
q.pop();
for (int d = 0; d < 4; d++) { // λ°©ν–₯ 탐색
int nx = x + directions[d][0];
int ny = y + directions[d][1];
if (nx >= 0 && nx < N && ny >= 0 && ny < M && map_copy[nx][ny] == 0) {
map_copy[nx][ny] = VIRUS; // 빈 칸을 λ°”μ΄λŸ¬μŠ€λ‘œ λ°”κΎΈκΈ°
q.push({nx, ny});
}
}
}
}

// μ•ˆμ „ μ˜μ—­ 크기 계산 ν•¨μˆ˜
int calculate_safe_area(vector<vector<int>>& map_copy) {
int safe_area = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
if (map_copy[i][j] == BLANK) { // 빈 칸의 개수
safe_area++;
}
}
}
return safe_area;
}

int main() {
cin >> N >> M;
initial_map.resize(N, vector<int>(M));

for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
cin >> initial_map[i][j];
if (initial_map[i][j] == BLANK) {
blank_map.push_back({ i, j }); // 빈 μΉΈ 지도 생성
}
}
}

vector<vector<pair<int, int>>> wall_combinations = building_walls(); // 빈 칸에 λ²½ μ„Έμš°κΈ°
int max_safe_area = 0; // μ•ˆμ „ μ˜μ—­μ˜ μ΅œλŒ€ 크기

for (const auto& walls : wall_combinations) { // λ²½ 3개λ₯Ό μ„Έμš΄ μ—¬λŸ¬ μ‘°ν•© 반볡
// 초기 맡 λ³΅μ‚¬ν•΄μ„œ κ·Έ 맡에 λ²½ 3개 μ„Έμš°λŠ” μ—¬λŸ¬ μ‘°ν•© 쀑 ν•œ 경우 적용
vector<vector<int>> map_copy = initial_map;
for (const auto& wall : walls) { // ν•œ κ²½μš°μ—μ„œ μ„Έμš΄ λ²½ 3개의 각각 μœ„μΉ˜μ— λ²½ μ„Έμš°κΈ°
map_copy[wall.first][wall.second] = WALL; // λ²½ μ„Έμš°κΈ°
}

bfs(map_copy); // λ°”μ΄λŸ¬μŠ€ μ£Όλ³€ μΉΈ 빈 칸이라면 λ°”μ΄λŸ¬μŠ€ 번짐

int safe_area = calculate_safe_area(map_copy); // μ•ˆμ „μ˜μ—­ 크기 계산
max_safe_area = max(max_safe_area, safe_area);
}

cout << max_safe_area << endl;
return 0;
}
41 changes: 41 additions & 0 deletions suhyun113/ν”Œλ‘œμ΄λ“œ-μ›Œμ…œ/10-suhyun113.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 11404 : ν”Œλ‘œμ΄λ“œ
import sys

input = sys.stdin.readline
INF = float('inf') # μ΅œλŒ€κ°’ μ •μ˜

# λ…Έλ“œμ˜ 개수(n)κ³Ό κ°„μ„ μ˜ 개수(m) μž…λ ₯
n = int(input()) # λ„μ‹œμ˜ 개수 n
m = int(input()) # λ²„μŠ€μ˜ 개수 m

# 2차원 리슀트 (κ·Έλž˜ν”„ ν‘œν˜„) λ§Œλ“€κ³ , λ¬΄ν•œλŒ€λ‘œ μ΄ˆκΈ°ν™”(ν”Œλ‘œμ΄λ“œ-μ›Œμ…œ = 이차원 λ°°μ—΄)
graph = [[INF] * (n + 1) for _ in range(n + 1)]

# iμ—μ„œ j둜 갈 수 μ—†λŠ” 경우,
# 자기 μžμ‹ μ—μ„œ 자기 μžμ‹ μœΌλ‘œ κ°€λŠ” λΉ„μš©μ€ 0으둜 μ΄ˆκΈ°ν™”(λŒ€κ°μ„ μ— ν•΄λ‹Ήν•˜λŠ” λΆ€λΆ„))
for i in range(1, n + 1):
for j in range(1, n + 1):
if i == j:
graph[i][j] = 0

# 각 간선에 λŒ€ν•œ 정보λ₯Ό μž…λ ₯λ°›μ•„, κ·Έ κ°’μœΌλ‘œ μ΄ˆκΈ°ν™”
for _ in range(m):
# A -> B둜 κ°€λŠ” λΉ„μš©μ„ C라고 μ„€μ •
i, j, cost = map(int, input().split())
if graph[i][j] > cost: # μ‹œμž‘ λ„μ‹œμ™€ 도착 λ„μ‹œ μ—°κ²°ν•˜λŠ” λ…Έμ„  ν•˜λ‚˜κ°€ x
graph[i][j] = cost

# 점화식에 따라 ν”Œλ‘œμ΄λ“œ μ›Œμ…œ μ•Œκ³ λ¦¬μ¦˜μ„ μˆ˜ν–‰(3쀑 forλ¬Έ)
for k in range(1, n + 1):
for i in range(1, n + 1):
for j in range(1, n + 1):
graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

# μˆ˜ν–‰λœ κ²°κ³Όλ₯Ό 좜λ ₯
for i in range(1, n + 1):
for j in range(1, n + 1):
if graph[i][j] == INF:
print(0, end=' ')
else:
print(graph[i][j], end=' ')
print()

0 comments on commit 56dc49e

Please sign in to comment.