Skip to content

Commit

Permalink
Merge branch 'main' into 11-rivkms
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn authored Jun 27, 2024
2 parents 82459ab + eee8b46 commit 67de9be
Show file tree
Hide file tree
Showing 9 changed files with 331 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@

**πŸ§©ν•΄λ‹Ή λ ˆν¬μ§€ν† λ¦¬ μŠ€ν„°λ”” μ°Έκ°€μž**

<table>
</table>

<br><br>

**πŸ†ν•΄λ‹Ή λ ˆν¬μ§€ν† λ¦¬ μŠ€ν„°λ”” 수료자**

<table>
<tr>
<td align="center"><a href="https://github.com/kjs254"><img src="https://avatars.githubusercontent.com/u/149364697?v=4" width="100px;" alt=""/>
Expand All @@ -58,8 +65,13 @@
<td align="center"><a href="https://github.com/mong3125" title="Code">mong3125</a></td>
<td align="center"><a href="https://github.com/rivkms" title="Code">rivkms</a></td>
</tr>
<tr>
<td align="center">24-02-12 ~<br> 24-05-11</a></td>
<td align="center">24-02-12 ~<br> 24-05-11</a></td>
<td align="center">24-02-12 ~<br> 24-05-11</a></td>
<td align="center">24-02-12 ~<br> 24-05-11</a></td>
</tr>
</table>

<br><br>

## 🀝 κ·œμΉ™
Expand Down
50 changes: 50 additions & 0 deletions YIM2UL2ET/BFS/13μ°¨μ‹œ - BOJ 7569.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <iostream>
#include <vector>
#include <queue>

struct idx {int z, y, x;};

int main(void)
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);

int m, n, h, res = 0, non = 0;
std::vector <idx> offset = {{1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}};
std::queue <idx> que[2];
bool curQueue = false;

std::cin >> n >> m >> h;
int box[h][m][n];

for (int z = 0; z < h; z++) {
for (int y = 0; y < m; y++) {
for (int x = 0; x < n; x++) {
std::cin >> box[z][y][x];
if (box[z][y][x] == 1) que[curQueue].push({z, y, x});
else if (box[z][y][x] == 0) non++;
}
}
}

while (!que[curQueue].empty() && non > 0) {
while (!que[curQueue].empty()) {
int z = que[curQueue].front().z, y = que[curQueue].front().y, x = que[curQueue].front().x;
for (idx set : offset) {
int zz = z + set.z, yy = y + set.y, xx = x + set.x;
if (zz >= 0 && zz < h && yy >= 0 && yy < m && xx >= 0 && xx < n && box[zz][yy][xx] == 0) {
box[zz][yy][xx] = 1, non--;
que[!curQueue].push({zz, yy, xx});
}
}
que[curQueue].pop();
}
curQueue = !curQueue;
res++;
}

if (non > 0) std::cout << -1;
else std::cout << res;

return 0;
}
3 changes: 3 additions & 0 deletions YIM2UL2ET/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
| 09μ°¨μ‹œ | 2024.03.07 | μž„μ˜ 정밀도 / 큰 수 μ—°μ‚° && μž¬κ·€ | [BOJ 1914](https://www.acmicpc.net/problem/1914) | [BOJ 1914 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/29) |
| 10μ°¨μ‹œ | 2024.03.10 | μŠ€νƒ | [BOJ 1406](https://www.acmicpc.net/problem/1406) | [BOJ 1406 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/31) |
| 11μ°¨μ‹œ | 2024.03.18 | μŠ€νƒ | [BOJ 1918](https://www.acmicpc.net/problem/1918) | [BOJ 1918 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/36) |
| 12μ°¨μ‹œ | 2024.03.28 | λΉ„νŠΈλ§ˆμŠ€ν‚Ή | [BOJ 11723](https://www.acmicpc.net/problem/11723) | [BOJ 11723 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/39) |
| 13μ°¨μ‹œ | 2024.04.01 | BFS | [BOJ 7569](https://www.acmicpc.net/problem/7569) | [BOJ 7569 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/42) |
| 14μ°¨μ‹œ | 2024.04.04 | μš°μ„ μˆœμœ„ 큐 | [BOJ 11286](https://www.acmicpc.net/problem/11286) | [BOJ 11286 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/43) |
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <iostream>

int main(void)
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);

int n, k, bits = 0;
std::string command;

std::cin >> n;
for (int i = 0; i < n; i++) {
std::cin >> command;
if (command == "add") {
std::cin >> k;
bits |= (1<<k);
}
else if (command == "remove") {
std::cin >> k;
bits &= ~(1<<k);
}
else if (command == "check") {
std::cin >> k;
if (bits & (1<<k)) std::cout << "1\n";
else std::cout << "0\n";
}
else if (command == "toggle") {
std::cin >> k;
bits ^= (1<<k);
}
else if (command == "all") bits = (1<<21)-1;
else bits = 0;
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <iostream>
#include <vector>

void cre_heap(std::vector <int> &heap, int key) {
int k = heap.size();
heap.push_back(key);
while (k > 1) {
if (abs(heap[k/2]) > abs(heap[k]) || (abs(heap[k/2]) == abs(heap[k]) && heap[k/2] > heap[k])) {
std::swap(heap[k], heap[k/2]);
k /= 2;
}
else break;
}
return;
}

void del_heap(std::vector <int> &heap) {
int k = 1;
heap[1] = heap.back(), heap.pop_back();
while (k * 2 <= heap.size()) {
if (k * 2 + 1 < heap.size() && (abs(heap[k*2+1]) < abs(heap[k*2]) || (abs(heap[k*2+1]) == abs(heap[k*2]) && heap[k*2+1] < heap[k*2])))
k = k*2+1;
else k = k*2;

if (abs(heap[k/2]) > abs(heap[k]) || (abs(heap[k/2]) == abs(heap[k]) && heap[k/2] > heap[k]))
std::swap(heap[k/2], heap[k]);
else break;
}
return;
}

int main(void) {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);

int n, k, x;
std::vector <int> abs_heap = {0};

std::cin >> n;
for (int i = 0; i < n; i++) {
std::cin >> x;
if (abs(x) > 0) cre_heap(abs_heap, x);
else if (abs_heap.size() > 1) {
std::cout << abs_heap[1] << '\n';
del_heap(abs_heap);
}
else std::cout << 0 << '\n';
}

}
44 changes: 44 additions & 0 deletions mong3125/이뢄탐색/BOJ1920_수찾기.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

static int[] A;
static int[] targets;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
A = new int[N];

StringTokenizer st = new StringTokenizer(br.readLine());
for (int i = 0; i < A.length; i++) {
A[i] = Integer.parseInt(st.nextToken());
}

int M = Integer.parseInt(br.readLine());
targets = new int[M];
st = new StringTokenizer(br.readLine());
for (int i = 0; i < targets.length; i++) {
targets[i] = Integer.parseInt(st.nextToken());
}

Arrays.sort(A);

for (int i = 0; i < targets.length; i++) {
int now = targets[i];
System.out.println(binary(0, A.length - 1, now) ? 1 : 0);
}
}

public static boolean binary(int from, int to, int n) {
if (from > to) return false;
int mid = (from + to) / 2;

if (A[mid] == n) return true;
else if (A[mid] > n) return binary(from, mid - 1, n);
else return binary(mid + 1, to, n);
}
}
34 changes: 34 additions & 0 deletions mong3125/이진탐색/BOJ1300_K번째수.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package 이진탐색;

import java.util.Scanner;

public class BOJ1300_K번째수 {
static int n;
static int k;
static int answer;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
k = sc.nextInt();

index(0, k);
System.out.println(answer);
}

public static void index(int front, int back) {
if (front > back) return;

int mid = (front + back) / 2;
int sum = 0;
for (int i = 1; i <= n; i++) {
sum += Math.min(mid / i, n);
}

if (sum < k) {
index(mid + 1, back);
} else {
answer = mid;
index(front, mid - 1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package 이진탐색;

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

public class BOJ2343_κΈ°νƒ€λ ˆμŠ¨ {

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

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

lectures = new int[N];
st = new StringTokenizer(br.readLine());

int sum = 0;
int max = 0;
for(int i = 0; i < N; i++) {
lectures[i] = Integer.parseInt(st.nextToken());
sum += lectures[i];
max = Math.max(max, lectures[i]);
}

// λΈ”λ£¨λ ˆμ΄μ˜ ν¬κΈ°λŠ” maxλΆ€ν„° sum 사이 일것이닀.
int result = minimumBlueray(max, sum);

System.out.println(result);
}

public static int minimumBlueray(int start, int end) {
if (start < end) return -1;

int mid = (start + end) / 2;

if (can(mid)) {
int more = minimumBlueray(start, mid - 1);
return more != -1 ? more : mid;
}
else return minimumBlueray(mid + 1, end);
}

public static boolean can(int blueray) {
int count = M;
int i = 0;
int stack = blueray;
while (count > 0) {
while (stack - lectures[i] > 0) {
if (i == N) return true;
stack -= lectures[i];
i++;
}

stack = blueray;
count--;
}

return false;
}
}
34 changes: 34 additions & 0 deletions rivkms/queue/11279.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <iostream>
#include <queue>

using namespace std;



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

int n, tmp;
cin >> n;

priority_queue<int> q;
vector<int> printq;
for(int i = 0; i < n; i++){
cin >> tmp;
if(tmp == 0){
if(q.empty()){
cout << 0 << "\n";
}
else{
cout << q.top() << "\n";
q.pop();
}
}
else{
q.push(tmp);
}
}
return 0;
}

0 comments on commit 67de9be

Please sign in to comment.