Skip to content

Commit

Permalink
Merge branch 'main' into 21-wkdghdwns199
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn authored May 10, 2024
2 parents 4c47304 + 5101ffe commit b8eab7a
Show file tree
Hide file tree
Showing 10 changed files with 216 additions and 45 deletions.
1 change: 1 addition & 0 deletions SeongHoonC/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
| 19차시 | 2024.04.04 | 그리디 | <a href="https://www.acmicpc.net/problem/16496">큰 수 만들기</a> |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/72 |
| 20차시 | 2024.04.07 | DP | <a href="https://www.acmicpc.net/problem/7579">앱</a> |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/75 |
| 21차시 | 2024.04.11 | DP | <a href="https://www.acmicpc.net/problem/1149">RGB거리</a> |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/77 |
| 21차시 | 2024.05.01 | DP | <a href="https://www.acmicpc.net/problem/11053">가장 긴 증가하는 부분 수열</a> |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/80 |
---
20 changes: 20 additions & 0 deletions SeongHoonC/dp/가장 긴 증가하는 부분 수열.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import java.io.BufferedReader
import java.io.InputStreamReader
import kotlin.math.max

fun main() {
val br = BufferedReader(InputStreamReader(System.`in`))
val n = br.readLine().toInt()
val arr = br.readLine().split(" ").map { it.toInt() }

val answer = Array(n) { 1 }

for (now in 1 until n) {
for (target in 0 until now) {
if (arr[target] < arr[now]) {
answer[now] = max(answer[now], answer[target] + 1)
}
}
}
println(answer.max())
}
44 changes: 44 additions & 0 deletions alstjr7437/BFS/연결-요소의-개수.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Foundation

let input = readLine()!.split(separator:
" ").map{ Int($0)!}

let n = input[0] , m = input[1]

var graph : [[Int]] = Array(repeating: [], count: n + 1)
var visited : [Bool] = Array(repeating: false, count: n + 1)
var result : Int = 0

for _ in 0..<m {
let tmp = readLine()!.split(separator: " ").map { Int($0)!}
graph[tmp[0]].append(tmp[1])
graph[tmp[1]].append(tmp[0])
}

func bfs(start: Int){
visited[start] = true
var queue: [Int] = [start]

var idx : Int = 0

while idx < queue.count{
let current = queue[idx]

idx += 1
for i in graph[current]{
if visited[i] == false {
queue.append(i)
visited[i] = true
}
}
}
}

for i in 1...n{
if visited[i] == false {
bfs(start : i)
result += 1
}
}

print(result)
5 changes: 4 additions & 1 deletion alstjr7437/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@
| 17차시 | 2024.03.16 | DP | <a href="https://www.acmicpc.net/problem/2228">구간 나누기</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/61 |
| 18차시 | 2024.03.23 | 다익스트라 | <a href="https://www.acmicpc.net/problem/1753">최단 경로</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/66 |
| 19차시 | 2024.03.27 | 문자열 | <a href="https://www.acmicpc.net/problem/5525">IOIOI</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/67 |
| 20차시 | 2024.04.03 | BFS | <a href="https://www.acmicpc.net/problem/1697">숨바꼭질</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/70 |
| 22차시 | 2024.04.13 | BFS | <a href="https://www.acmicpc.net/problem/11724">연결 요소의 개수</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/78 |
| 21차시 | 2024.04.06 | 비트마스킹 | <a href="https://www.acmicpc.net/problem/11723">집합</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/74 |
| 22차시 | 2024.04.13 | BFS | <a href="https://www.acmicpc.net/problem/11724">연결 요소의 개수</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/78 |
| 23차시 | 2024.05.01 || <a href="https://school.programmers.co.kr/learn/courses/30/lessons/42587">프로세스</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/79 |
86 changes: 86 additions & 0 deletions alstjr7437/비트마스킹/집합.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import sys

input = sys.stdin.readline

m = int(input())

result = 0

for _ in range(m):
cmd = input().split()
print(result)

if cmd[0] == "add":
result |= (1 << int(cmd[1]))

if cmd[0] == "remove":
result &= ~(1 << int(cmd[1]))

if cmd[0] == "check":
if result & (1 << int(cmd[1])):
print(1)
else:
print(0)

if cmd[0] == "toggle":
result ^= (1 << int(cmd[1]))

if cmd[0] == "all":
result = (1 << 21) - 1

if cmd[0] == "empty":
result = 0


# for _ in range(m):
# cmd = input().split()

# if cmd[0] == "add":
# result[int(cmd[1])] = 1

# if cmd[0] == "remove":
# result[int(cmd[1])] = 0

# if cmd[0] == "check":
# if result[int(cmd[1])] == 1:
# print(1)
# else :
# print(0)

# if cmd[0] == "toggle":
# if result[int(cmd[1])] == 1:
# result[int(cmd[1])] = 0
# else :
# result[int(cmd[1])] = 1

# if cmd[0] == "all":
# result = [1] * len(result)

# if cmd[0] == "empty":
# result = [0] * len(result)

"""
S = set()
for _ in range(m):
temp = input().split()
if temp[0] == "add":
S.add(int(temp[1]))
if temp[0] == "remove":
S.discard(int(temp[1]))
if temp[0] == "check":
if int(temp[1]) in S:
print(1)
else :
print(0)
if temp[0] == "toggle":
if int(temp[1]) in S:
S.discard(int(temp[1]))
else:
S.add(int(temp[1]))
if temp[0] == "all":
S = set([i for i in range(1, 21)])
if temp[0] == "empty":
S = set()
"""
29 changes: 29 additions & 0 deletions alstjr7437/큐/프로세스.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Foundation

func solution(_ priorities:[Int], _ location:Int) -> Int {
var result = 0
var priorities = priorities
var location = location

while priorities.count != 0 {
location -= 1
let p_max = priorities.max()!
let temp = priorities[0]
if p_max != temp { // max가 아닐 경우(빼야할 경우가 아닌 경우)
priorities.append(temp) // 뒤에 넣기
priorities.removeFirst() // 처음꺼 빼기
if location < 0 { // location이 음수면 제일 뒤에서 부터
location = priorities.count - 1
}
} else { // max일 경우(빼야할 경우)
priorities.removeFirst()
result += 1
if location < 0 { // location이 적절하게 오면 멈추기
break
}
}

}

return result
}
19 changes: 0 additions & 19 deletions wkdghdwns199/ACM-25192.py

This file was deleted.

25 changes: 0 additions & 25 deletions wkdghdwns199/ACM-26069.py

This file was deleted.

1 change: 1 addition & 0 deletions wkdghdwns199/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
| 17차시 | 2024.03.27 | DP | <a href="https://www.acmicpc.net/problem/9184">신나는 함수 실행</a> | <a href="https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/68">2024.03.27</a> |
| 18차시 | 2024.04.03 | 집합과 맵 | <a href="https://www.acmicpc.net/problem/26069">절댓값 힙</a> | <a href="https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/73">2024.04.03</a> |
| 19차시 | 2024.04.07 | 조합론 | <a href="https://www.acmicpc.net/problem/25192">인사성 밝은 곰곰이</a> | <a href="https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/76">2024.04.07</a> |
| 20차시 | 2024.05.02 | 그리디 | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/42862?itm_content=course14743">체육복</a> | <a href="">2024.05.02</a> |
| 21차시 | 2024.05.05 | 그리디 | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/42860">조이스틱</a> | <a href="">2024.04.07</a> |

31 changes: 31 additions & 0 deletions wkdghdwns199/그리디/체육복.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.util.*;

class Solution {
public int solution(int n, int[] lost, int[] reserve) {
Arrays.sort(lost);
Arrays.sort(reserve);
int answer = n-lost.length;
for (int i=0; i<lost.length; i++){
for (int j=0; j<reserve.length; j++){
if (lost[i] == reserve[j]){
answer++;
lost[i] = -1;
reserve[j] = -1;
break;
}
}
}

for (int i=0; i<lost.length; i++){
for (int j=0; j<reserve.length; j++){
if (lost[i]-1 == reserve[j] || lost[i]+1 == reserve[j]){
answer++;
reserve[j]=-1;
break;
}
}
}

return answer;
}
}

0 comments on commit b8eab7a

Please sign in to comment.