Skip to content

Commit

Permalink
Merge branch 'main' into 10-rivkms
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn authored Jun 27, 2024
2 parents ed0996d + c98fcb4 commit 11b7356
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 2 deletions.
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 @@ -12,4 +12,7 @@
| 08μ°¨μ‹œ | 2024.03.04 | μž¬κ·€ | [BOJ 10994](https://www.acmicpc.net/problem/10994) | [BOJ 10994 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/27) |
| 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) |
---
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;
}
43 changes: 43 additions & 0 deletions YIM2UL2ET/μŠ€νƒ/11μ°¨μ‹œ - BOJ 1918.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <iostream>
#include <stack>

int main(void)
{
char ch;
std::stack <char> stk;
std::string res;

ch = getchar();
while (ch != '\n') {
if (ch == '+' || ch == '-') {
while(!stk.empty() && stk.top() != '(') {
res.push_back(stk.top());
stk.pop();
}
stk.push(ch);
}
else if (ch == '*' || ch == '/') {
if (!stk.empty() && (stk.top() == '*' || stk.top() == '/')) {
res.push_back(stk.top());
stk.pop();
}
stk.push(ch);
}
else if (ch == ')') {
while (!stk.empty() && stk.top() != '(') {
res.push_back(stk.top());
stk.pop();
}
if (!stk.empty()) stk.pop();
}
else if (ch == '(') stk.push(ch);
else res.push_back(ch);
ch = getchar();
}
while (!stk.empty()) {
res.push_back(stk.top());
stk.pop();
}
std::cout << res;
return 0;
}
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;
}
}
2 changes: 1 addition & 1 deletion rivkms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
| 7μ°¨μ‹œ | 2024.03.01 | DP | [연속합](https://www.acmicpc.net/problem/1912) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/25) |
| 8μ°¨μ‹œ | 2024.03.01 | Greedy | [νšŒμ˜μ‹€ λ°°μ •](https://www.acmicpc.net/problem/1931) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/28) |
| 9μ°¨μ‹œ | 2024.03.22 | two-pointer | [두 수의 ν•©](https://www.acmicpc.net/problem/3273) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/38) |
| 10μ°¨μ‹œ | 2024.03.28 | queue | [μ΅œλŒ€νž™](https://www.acmicpc.net/problem/11279) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/40) |
| 10μ°¨μ‹œ | 2024.03.28 | queue | [μ΅œλŒ€νž™](https://www.acmicpc.net/problem/11279) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/40) |
36 changes: 36 additions & 0 deletions rivkms/Two_pointer/3273.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
int n, goal;
int a, b, cnt = 0;;
cin >> n;
a = 0;
b = n-1;
vector<int> vec(n,0);
for(int i = 0; i<n; i++){
cin >> vec[i];
}
sort(vec.begin(), vec.end());
cin >> goal;
while(true){
if(b<=a){
cout << cnt;
break;
}
if(vec[a]+vec[b] == goal){
cnt++;
a+=1;
b-=1;
}
else if(vec[a]+vec[b] > goal){
b-=1;
}
else{
a+=1;
}
}
return 0;
}

0 comments on commit 11b7356

Please sign in to comment.