From fefcebc9f51d5fceffeaba2d26ba04dc895447a9 Mon Sep 17 00:00:00 2001 From: InSange Date: Thu, 4 Apr 2024 13:11:03 +0900 Subject: [PATCH 01/24] =?UTF-8?q?2024-04-04=20=EB=AC=B8=EC=9E=90=EC=97=B4?= =?UTF-8?q?=20=ED=8F=AD=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- InSange/README.md | 3 +- "InSange/\354\212\244\355\203\235/9935.cpp" | 54 +++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 "InSange/\354\212\244\355\203\235/9935.cpp" diff --git a/InSange/README.md b/InSange/README.md index a494ef3..b510896 100644 --- a/InSange/README.md +++ b/InSange/README.md @@ -7,6 +7,7 @@ | 3차시 | 2024.03.19 | 플로이드 워셜 | [앱](https://www.acmicpc.net/problem/7579) | [#3](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/9) | | 4차시 | 2024.03.25 | 다익스트라 | [파티](https://www.acmicpc.net/problem/1238) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/15)| | 5차시 | 2024.03.27 | DP | [RGB거리2](https://www.acmicpc.net/problem/17404) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)] -| 6차시 | 2024.04.01 | 최소신장트리 | [행성 터널](https://www.acmicpc.net/problem/2887) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)] +| 6차시 | 2024.04.01 | 최소신장트리 | [행성 터널](https://www.acmicpc.net/problem/2887) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/24)] +| 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)] ======= --- diff --git "a/InSange/\354\212\244\355\203\235/9935.cpp" "b/InSange/\354\212\244\355\203\235/9935.cpp" new file mode 100644 index 0000000..1a8b973 --- /dev/null +++ "b/InSange/\354\212\244\355\203\235/9935.cpp" @@ -0,0 +1,54 @@ +#include + +using namespace std; + +string s, boom; +int blen; + +void Solve() +{ + cin >> s >> boom; + + blen = boom.length(); + + string st = ""; + for (char c : s) + { + st.push_back(c); + + if (c == boom[blen-1] && st.size() >= blen) + { + bool flag = true; + + for (int i = 0; i < blen; i++) + { + if (boom[i] != st[st.length() - blen + i]) + { + flag = false; + break; + } + } + + if (flag) + { + for (int i = 0; i < blen; i++) + { + st.pop_back(); + } + } + } + } + + if (st == "") cout << "FRULA"; + else cout << st; +} + +int main() +{ + cin.tie(nullptr); + ios::sync_with_stdio(false); + + Solve(); + + return 0; +} \ No newline at end of file From 5e1f26399476e70ba349162c8b8e7c128a892855 Mon Sep 17 00:00:00 2001 From: yuyu0830 Date: Thu, 4 Apr 2024 14:12:46 +0900 Subject: [PATCH 02/24] =?UTF-8?q?24-04-04=20=EC=A0=80=EC=9A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuyu0830/README.md | 4 +++ "yuyu0830/\354\210\230\355\225\231/2437.cpp" | 34 ++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 "yuyu0830/\354\210\230\355\225\231/2437.cpp" diff --git a/yuyu0830/README.md b/yuyu0830/README.md index b957bf0..c6d506a 100644 --- a/yuyu0830/README.md +++ b/yuyu0830/README.md @@ -6,4 +6,8 @@ | 2차시 | 2024.03.15 | 탐색 | [숨바꼭질 2](https://www.acmicpc.net/problem/12851) | - | | 3차시 | 2024.03.20 | 탐색 | [하이퍼 토마토](https://www.acmicpc.net/problem/17114) | - | | 4차시 | 2024.03.26 | 분할정복 | [행렬 제곱](https://www.acmicpc.net/problem/10830) | - | +| 5차시 | 2024.03.29 | 탐색 | [스도쿠](https://www.acmicpc.net/problem/2239) | - | +| 6차시 | 2024.04.03 | 자료구조 | [나만 안되는 연애](https://www.acmicpc.net/problem/14621) | - | +| 7차시 | 2024.04.04 | 저울 | [저울](https://www.acmicpc.net/problem/2437) | - | + --- diff --git "a/yuyu0830/\354\210\230\355\225\231/2437.cpp" "b/yuyu0830/\354\210\230\355\225\231/2437.cpp" new file mode 100644 index 0000000..cfba534 --- /dev/null +++ "b/yuyu0830/\354\210\230\355\225\231/2437.cpp" @@ -0,0 +1,34 @@ +#include +#include + +using namespace std; + +int main() { + priority_queue, greater > q; + int n; cin >> n; + + for (int i = 0; i < n; i++) { + int t; cin >> t; + q.push(t); + } + + bool first = true; + int max = 1; + + while (!q.empty()) { + int t = q.top(); + q.pop(); + + // when First number isn't 1 + if (first && t != 1) + break; + + first = false; + + // can search more? + if (t <= max) max += t; + else break; + } + + printf("%d\n", max); +} \ No newline at end of file From 9a07b14499e1a78d5c1666c91c0b9bbbd88d1fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=A0=EC=9A=B0?= <51250442+InSange@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:30:45 +0900 Subject: [PATCH 03/24] 7-InSange --- InSange/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InSange/README.md b/InSange/README.md index b510896..eaec8b6 100644 --- a/InSange/README.md +++ b/InSange/README.md @@ -8,6 +8,6 @@ | 4차시 | 2024.03.25 | 다익스트라 | [파티](https://www.acmicpc.net/problem/1238) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/15)| | 5차시 | 2024.03.27 | DP | [RGB거리2](https://www.acmicpc.net/problem/17404) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)] | 6차시 | 2024.04.01 | 최소신장트리 | [행성 터널](https://www.acmicpc.net/problem/2887) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/24)] -| 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)] +| 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] ======= --- From ceb3d19eb87b4e310991a694dca5484ffd743cc4 Mon Sep 17 00:00:00 2001 From: seongwon030 <105052068+seongwon030@users.noreply.github.com> Date: Fri, 5 Apr 2024 23:50:39 +0900 Subject: [PATCH 04/24] =?UTF-8?q?2024-04-05=20=EC=98=A4=ED=81=B0=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\230\244\355\201\260\354\210\230.py" | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 "seongwon030/\354\212\244\355\203\235/\354\230\244\355\201\260\354\210\230.py" diff --git "a/seongwon030/\354\212\244\355\203\235/\354\230\244\355\201\260\354\210\230.py" "b/seongwon030/\354\212\244\355\203\235/\354\230\244\355\201\260\354\210\230.py" new file mode 100644 index 0000000..c2022c0 --- /dev/null +++ "b/seongwon030/\354\212\244\355\203\235/\354\230\244\355\201\260\354\210\230.py" @@ -0,0 +1,10 @@ +n = int(input()) +A = list(map(int,input().split())) +NGE = [-1]*n +stack = [0] + +for i in range(1,n): + while stack and A[stack[-1]] < A[i]: + NGE[stack.pop()] = A[i] + stack.append(i) +print(*NGE) \ No newline at end of file From ba48c4957aae3ea8b59173d66e8e7c58197d235f Mon Sep 17 00:00:00 2001 From: dhlee777 Date: Mon, 8 Apr 2024 10:53:41 +0900 Subject: [PATCH 05/24] =?UTF-8?q?2024-04-08=20n=EA=B3=BCm(5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "dhlee777/backtracking/n\352\263\274m(5).cpp" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "dhlee777/backtracking/n\352\263\274m(5).cpp" diff --git "a/dhlee777/backtracking/n\352\263\274m(5).cpp" "b/dhlee777/backtracking/n\352\263\274m(5).cpp" new file mode 100644 index 0000000..468d584 --- /dev/null +++ "b/dhlee777/backtracking/n\352\263\274m(5).cpp" @@ -0,0 +1,36 @@ +#include +#include +#include +using namespace std; +int num_size, picked_size; +int num[8]; //Է¹ ڵ ϴ 迭 +bool visited[8]; //湮ߴ Ȯϱ 迭 +vectorv; //ڵ ֱ +void dfs(int cnt, int vt) { //cnt 湮 ī,vt ڸ Ÿ. + if (cnt == picked_size) { // 湮 Է¹ ϴ ,dfs(3,2) °ڸ num[2]϶ ִ Լ + + for (auto k : v) { + cout << k << " "; //Ϳ ִ + } + cout << "\n"; + } + for (int j = 0; j < num_size; j++) { // ƴ϶ ̹Ƿ ε0 Ž + if (!visited[j]) { //num[j] 湮 ʾҴٸ + visited[j] = true; //湮 ǥø Ͽְ + v.push_back(num[j]); //Ϳ ־ش. + dfs(cnt + 1, j); //īƮ ÷ְ j̵ ٽ Ž + v.pop_back(); //Ž ٸ ͳ ϳ ش. + visited[j] = false; //ٸ 츦 j 湮ߴٰ ٲش. + } + } +} +int main(void) { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cin >> num_size >> picked_size; + for (int i = 0; i < num_size; i++) { + cin >> num[i]; + } + sort(num, num + num_size); //Է¹ ׹̹Ƿ ش. + dfs(0, 0); +} \ No newline at end of file From 323b56348145655e865a1e600b73bf8268fcd0d0 Mon Sep 17 00:00:00 2001 From: InSange Date: Tue, 9 Apr 2024 19:45:25 +0900 Subject: [PATCH 06/24] 8-InSange --- InSange/README.md | 3 +- .../2470.cpp" | 96 +++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 "InSange/\355\210\254\355\217\254\354\235\270\355\204\260/2470.cpp" diff --git a/InSange/README.md b/InSange/README.md index b510896..0960f73 100644 --- a/InSange/README.md +++ b/InSange/README.md @@ -8,6 +8,7 @@ | 4차시 | 2024.03.25 | 다익스트라 | [파티](https://www.acmicpc.net/problem/1238) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/15)| | 5차시 | 2024.03.27 | DP | [RGB거리2](https://www.acmicpc.net/problem/17404) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)] | 6차시 | 2024.04.01 | 최소신장트리 | [행성 터널](https://www.acmicpc.net/problem/2887) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/24)] -| 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)] +| 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] +| 8차시 | 2024.04.09 | 투 포인터 | [두 용액](https://www.acmicpc.net/problem/2470) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] ======= --- diff --git "a/InSange/\355\210\254\355\217\254\354\235\270\355\204\260/2470.cpp" "b/InSange/\355\210\254\355\217\254\354\235\270\355\204\260/2470.cpp" new file mode 100644 index 0000000..dcb049f --- /dev/null +++ "b/InSange/\355\210\254\355\217\254\354\235\270\355\204\260/2470.cpp" @@ -0,0 +1,96 @@ +#include +#include +#include + +using namespace std; + +const int MAX_VAL = 1999999999; + +int N, num, minVal, aanswer, banswer; +vector acid; // 꼺 +vector basic; // ⼺ + +bool cmp(int a, int b) +{ + return a > b; +} + +void Input() +{ + cin >> N; + + for (int i = 0; i < N; i++) + { + cin >> num; + (num > 0) ? acid.push_back(num) : basic.push_back(num); + } + + sort(acid.begin(), acid.end()); + sort(basic.begin(), basic.end(), cmp); + + minVal = MAX_VAL; +} + +void Solve() +{ + int a_index = 0; + int b_index = 0; + while (a_index < acid.size() && b_index < basic.size()) + { + int anum, bnum; + anum = acid[a_index]; + bnum = basic[b_index]; + + if (abs(anum + bnum) < minVal) + { + aanswer = anum; + banswer = bnum; + minVal = abs(anum + bnum); + } + + (abs(anum) > abs(bnum)) ? b_index++ : a_index++; + } + + int sum; + if (acid.size() > 1) + { + sum = abs(acid[0] + acid[1]); + if (sum < minVal) + { + aanswer = acid[1]; + banswer = acid[0]; + } + } + if (basic.size() > 1) + { + sum = abs(basic[0] + basic[1]); + if (sum < minVal) + { + aanswer = basic[0]; + banswer = basic[1]; + } + } + if (acid.empty()) + { + aanswer = basic[0]; + banswer = basic[1]; + } + if (basic.empty()) + { + aanswer = acid[1]; + banswer = acid[0]; + } + + cout << banswer << " " << aanswer; +} + +int main() +{ + cin.tie(nullptr); + ios::sync_with_stdio(false); + + Input(); + Solve(); + + return 0; +} \ No newline at end of file From 57b94ef84b556fd8e0993d76e9211b121e93c697 Mon Sep 17 00:00:00 2001 From: InSange Date: Tue, 9 Apr 2024 19:45:42 +0900 Subject: [PATCH 07/24] Revert "8-InSange" This reverts commit 323b56348145655e865a1e600b73bf8268fcd0d0. --- InSange/README.md | 3 +- .../2470.cpp" | 96 ------------------- 2 files changed, 1 insertion(+), 98 deletions(-) delete mode 100644 "InSange/\355\210\254\355\217\254\354\235\270\355\204\260/2470.cpp" diff --git a/InSange/README.md b/InSange/README.md index 0960f73..b510896 100644 --- a/InSange/README.md +++ b/InSange/README.md @@ -8,7 +8,6 @@ | 4차시 | 2024.03.25 | 다익스트라 | [파티](https://www.acmicpc.net/problem/1238) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/15)| | 5차시 | 2024.03.27 | DP | [RGB거리2](https://www.acmicpc.net/problem/17404) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)] | 6차시 | 2024.04.01 | 최소신장트리 | [행성 터널](https://www.acmicpc.net/problem/2887) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/24)] -| 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] -| 8차시 | 2024.04.09 | 투 포인터 | [두 용액](https://www.acmicpc.net/problem/2470) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] +| 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)] ======= --- diff --git "a/InSange/\355\210\254\355\217\254\354\235\270\355\204\260/2470.cpp" "b/InSange/\355\210\254\355\217\254\354\235\270\355\204\260/2470.cpp" deleted file mode 100644 index dcb049f..0000000 --- "a/InSange/\355\210\254\355\217\254\354\235\270\355\204\260/2470.cpp" +++ /dev/null @@ -1,96 +0,0 @@ -#include -#include -#include - -using namespace std; - -const int MAX_VAL = 1999999999; - -int N, num, minVal, aanswer, banswer; -vector acid; // 꼺 -vector basic; // ⼺ - -bool cmp(int a, int b) -{ - return a > b; -} - -void Input() -{ - cin >> N; - - for (int i = 0; i < N; i++) - { - cin >> num; - (num > 0) ? acid.push_back(num) : basic.push_back(num); - } - - sort(acid.begin(), acid.end()); - sort(basic.begin(), basic.end(), cmp); - - minVal = MAX_VAL; -} - -void Solve() -{ - int a_index = 0; - int b_index = 0; - while (a_index < acid.size() && b_index < basic.size()) - { - int anum, bnum; - anum = acid[a_index]; - bnum = basic[b_index]; - - if (abs(anum + bnum) < minVal) - { - aanswer = anum; - banswer = bnum; - minVal = abs(anum + bnum); - } - - (abs(anum) > abs(bnum)) ? b_index++ : a_index++; - } - - int sum; - if (acid.size() > 1) - { - sum = abs(acid[0] + acid[1]); - if (sum < minVal) - { - aanswer = acid[1]; - banswer = acid[0]; - } - } - if (basic.size() > 1) - { - sum = abs(basic[0] + basic[1]); - if (sum < minVal) - { - aanswer = basic[0]; - banswer = basic[1]; - } - } - if (acid.empty()) - { - aanswer = basic[0]; - banswer = basic[1]; - } - if (basic.empty()) - { - aanswer = acid[1]; - banswer = acid[0]; - } - - cout << banswer << " " << aanswer; -} - -int main() -{ - cin.tie(nullptr); - ios::sync_with_stdio(false); - - Input(); - Solve(); - - return 0; -} \ No newline at end of file From 894a6a355532e2aa1731cecf685c90936b4e5f44 Mon Sep 17 00:00:00 2001 From: InSange Date: Tue, 9 Apr 2024 19:48:57 +0900 Subject: [PATCH 08/24] =?UTF-8?q?2024-04-09=20=EB=91=90=20=EC=9A=A9?= =?UTF-8?q?=EC=95=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- InSange/README.md | 3 +- .../2470.cpp" | 96 +++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 "InSange/\355\210\254\355\217\254\354\235\270\355\204\260/2470.cpp" diff --git a/InSange/README.md b/InSange/README.md index b510896..0960f73 100644 --- a/InSange/README.md +++ b/InSange/README.md @@ -8,6 +8,7 @@ | 4차시 | 2024.03.25 | 다익스트라 | [파티](https://www.acmicpc.net/problem/1238) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/15)| | 5차시 | 2024.03.27 | DP | [RGB거리2](https://www.acmicpc.net/problem/17404) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)] | 6차시 | 2024.04.01 | 최소신장트리 | [행성 터널](https://www.acmicpc.net/problem/2887) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/24)] -| 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)] +| 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] +| 8차시 | 2024.04.09 | 투 포인터 | [두 용액](https://www.acmicpc.net/problem/2470) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] ======= --- diff --git "a/InSange/\355\210\254\355\217\254\354\235\270\355\204\260/2470.cpp" "b/InSange/\355\210\254\355\217\254\354\235\270\355\204\260/2470.cpp" new file mode 100644 index 0000000..dcb049f --- /dev/null +++ "b/InSange/\355\210\254\355\217\254\354\235\270\355\204\260/2470.cpp" @@ -0,0 +1,96 @@ +#include +#include +#include + +using namespace std; + +const int MAX_VAL = 1999999999; + +int N, num, minVal, aanswer, banswer; +vector acid; // 꼺 +vector basic; // ⼺ + +bool cmp(int a, int b) +{ + return a > b; +} + +void Input() +{ + cin >> N; + + for (int i = 0; i < N; i++) + { + cin >> num; + (num > 0) ? acid.push_back(num) : basic.push_back(num); + } + + sort(acid.begin(), acid.end()); + sort(basic.begin(), basic.end(), cmp); + + minVal = MAX_VAL; +} + +void Solve() +{ + int a_index = 0; + int b_index = 0; + while (a_index < acid.size() && b_index < basic.size()) + { + int anum, bnum; + anum = acid[a_index]; + bnum = basic[b_index]; + + if (abs(anum + bnum) < minVal) + { + aanswer = anum; + banswer = bnum; + minVal = abs(anum + bnum); + } + + (abs(anum) > abs(bnum)) ? b_index++ : a_index++; + } + + int sum; + if (acid.size() > 1) + { + sum = abs(acid[0] + acid[1]); + if (sum < minVal) + { + aanswer = acid[1]; + banswer = acid[0]; + } + } + if (basic.size() > 1) + { + sum = abs(basic[0] + basic[1]); + if (sum < minVal) + { + aanswer = basic[0]; + banswer = basic[1]; + } + } + if (acid.empty()) + { + aanswer = basic[0]; + banswer = basic[1]; + } + if (basic.empty()) + { + aanswer = acid[1]; + banswer = acid[0]; + } + + cout << banswer << " " << aanswer; +} + +int main() +{ + cin.tie(nullptr); + ios::sync_with_stdio(false); + + Input(); + Solve(); + + return 0; +} \ No newline at end of file From af6a3875cf4adeee6d02e431ee6fcbe1ac8e0118 Mon Sep 17 00:00:00 2001 From: yuyu0830 Date: Thu, 11 Apr 2024 16:27:57 +0900 Subject: [PATCH 09/24] =?UTF-8?q?24-04-11=20=EB=B3=B4=EC=84=9D=20=EB=8F=84?= =?UTF-8?q?=EB=91=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../12851.cpp" | 85 ------------------- .../1202.cpp" | 56 ++++++++++++ .../\355\203\220\354\203\211/1865.cpp" | 0 3 files changed, 56 insertions(+), 85 deletions(-) delete mode 100644 "yuyu0830/\341\204\220\341\205\241\341\206\267\341\204\211\341\205\242\341\206\250/12851.cpp" create mode 100644 "yuyu0830/\352\267\270\353\246\254\353\224\224/1202.cpp" rename "yuyu0830/\341\204\220\341\205\241\341\206\267\341\204\211\341\205\242\341\206\250/1865.cpp" => "yuyu0830/\355\203\220\354\203\211/1865.cpp" (100%) diff --git "a/yuyu0830/\341\204\220\341\205\241\341\206\267\341\204\211\341\205\242\341\206\250/12851.cpp" "b/yuyu0830/\341\204\220\341\205\241\341\206\267\341\204\211\341\205\242\341\206\250/12851.cpp" deleted file mode 100644 index bec7364..0000000 --- "a/yuyu0830/\341\204\220\341\205\241\341\206\267\341\204\211\341\205\242\341\206\250/12851.cpp" +++ /dev/null @@ -1,85 +0,0 @@ -// BFS 골드 4 숨바꼭질 2 https://www.acmicpc.net/problem/12851 -#include -#include -#include - -using namespace std; - -int n, k; -int dist[100001] = {0, }; -bool visited[100001] = {0, }; - -void solve() { - // 2개의 큐를 번갈아 사용하기 위한 큐 배열, 불리언 변수 - priority_queue, greater> q[2]; - bool e = false; - - // 현재 탐색에서 탐색중인 위치를 저장 - vector visitedVec; - - q[e].push(n); - dist[n] = 1; - visited[n] = 1; - - if (n == k) { - printf("0\n1"); - return; - } - - int time = 1, cnt = 0; - - while (true) { - while (!q[e].empty()) { - int cur = q[e].top(); - - q[e].pop(); - - for (int i : {cur - 1, cur * 2, cur + 1}) { - if (i < 0 || i > 100000) continue; - - // 목표 위치에 도착한 경우 경우의 수 저장 - if (i == k) cnt += dist[cur] + 1; - - // 첫 방문인 경우 다음 탐색 큐에 저장 - if (!dist[i]) { - q[!e].push(i); - visitedVec.push_back(i); - } - - // 방문한 위치에 현재 위치의 경우의 수 더하기 - // 이전 탐색에서 탐색한 위치는 방문 안하도록 - if (!visited[i]) - dist[i] += dist[cur]; - - // 탐색 도중 숫자가 커지면 탐색을 종료, 탐색중 큐 비우기 - if (cur > k) break; - } - - // 숫자가 커져서 탐색을 종료하면 남은 큐는 비워주기 - if (cur > k) { - q[e] = priority_queue , greater> (); - break; - } - } - - if (cnt) { - printf("%d\n%d", time, dist[k]); - break; - } - - // 이번 탐색에서 방문한 노드들 전부 표시 해주기 - while (!visitedVec.empty()) { - int v = visitedVec.back(); - visitedVec.pop_back(); - visited[v] = 1; - } - - e = !e; - time++; - } -} - -int main() { - cin >> n >> k; - solve(); -} \ No newline at end of file diff --git "a/yuyu0830/\352\267\270\353\246\254\353\224\224/1202.cpp" "b/yuyu0830/\352\267\270\353\246\254\353\224\224/1202.cpp" new file mode 100644 index 0000000..0799d4d --- /dev/null +++ "b/yuyu0830/\352\267\270\353\246\254\353\224\224/1202.cpp" @@ -0,0 +1,56 @@ +#include +#include +#include +#include + +using namespace std; + +typedef pair ii; + +#define fastio cin.tie(NULL); cin.sync_with_stdio(false); + +ii gems[300001]; +int bags[300001] = {0, }; + +priority_queue q; + +int main() { + fastio + + // input + int n, k; cin >> n >> k; + + for (int i = 0; i < n; i++) + cin >> gems[i].first >> gems[i].second; + + for (int i = 0; i < k; i++) + cin >> bags[i]; + + // Sort gems, bags ascending order + // gems sort by weight + sort(gems, gems + n); + sort(bags, bags + k); + + // ans can be more then int max value + // 300,000 * 1,000,000 + long long int ans = 0; + int cnt = 0; + + for (int i = 0; i < k; i++) { + int curBag = bags[i]; + + // push all the gems that can put in current bag into the priority queue + while (cnt < n && gems[cnt].first <= curBag) { + q.push(gems[cnt].second); + cnt++; + } + + // if queue is not empty, top of queue will be max price that can get in current bag + if (!q.empty()) { + ans += q.top(); + q.pop(); + } + } + + printf("%lld\n", ans); +} \ No newline at end of file diff --git "a/yuyu0830/\341\204\220\341\205\241\341\206\267\341\204\211\341\205\242\341\206\250/1865.cpp" "b/yuyu0830/\355\203\220\354\203\211/1865.cpp" similarity index 100% rename from "yuyu0830/\341\204\220\341\205\241\341\206\267\341\204\211\341\205\242\341\206\250/1865.cpp" rename to "yuyu0830/\355\203\220\354\203\211/1865.cpp" From 889fbe00dce0fc1d88b824ca8b782b5d5652eb23 Mon Sep 17 00:00:00 2001 From: dhlee777 Date: Fri, 12 Apr 2024 16:05:42 +0900 Subject: [PATCH 10/24] =?UTF-8?q?2024-04-08=20n=EA=B3=BCm(5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dhlee777/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dhlee777/README.md b/dhlee777/README.md index a897fc2..d97301d 100644 --- a/dhlee777/README.md +++ b/dhlee777/README.md @@ -7,6 +7,9 @@ | 3차시 | 2024.03.23 | union-find | [집합의 표현](https://www.acmicpc.net/problem/1717) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/14)| | 4차시 | 2024.03.25 | BFS | [바이러스](https://www.acmicpc.net/problem/2606) | [#17](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/17)| | 5차시 | 2024.03.30 | mst | [최소스패닝트리](https://www.acmicpc.net/problem/1197) | [#21](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/21)| +| 6차시 | 2024.04.04 | backtracking | [스타트와링크](https://www.acmicpc.net/problem/14889) | [#29](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/29)| +| 7차시 | 2024.04.08 | backtracking | [n과m(5)](https://www.acmicpc.net/problem/15654) | [#31](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/31)| + From 9aeab0637db9b3da2e428680ebb20facdc79d587 Mon Sep 17 00:00:00 2001 From: dhlee777 Date: Fri, 12 Apr 2024 16:31:43 +0900 Subject: [PATCH 11/24] =?UTF-8?q?2024-04-12=20=EC=A0=81=EB=A1=9D=EC=83=89?= =?UTF-8?q?=EC=95=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1\353\241\235\354\203\211\354\225\275.cpp" | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 "dhlee777/dfs/\354\240\201\353\241\235\354\203\211\354\225\275.cpp" diff --git "a/dhlee777/dfs/\354\240\201\353\241\235\354\203\211\354\225\275.cpp" "b/dhlee777/dfs/\354\240\201\353\241\235\354\203\211\354\225\275.cpp" new file mode 100644 index 0000000..11902db --- /dev/null +++ "b/dhlee777/dfs/\354\240\201\353\241\235\354\203\211\354\225\275.cpp" @@ -0,0 +1,55 @@ +#include +using namespace std; +char color[100][100]; // ׸ +char color2[100][100]; //ϻ ׸ +bool visited[100][100]; // ׸ 湮 +bool visited2[100][100]; //ϻ ׸ 湮 +string line; // Է ޱ Ʈ +int siz; //׸ +int coun = 0; // ׸ ǰ +int coun2 = 0; //ϻ ǰ +int x[4]={0,0,-1,1}; //¿ Ž xǥ ̵ +int y[4] = { -1,1,0,0 }; // yǥ ̵ + +void dfs(int a,int b,char color[][100], bool visited[][100]) { //x:Ž ǥ,y:Ž yǥ color: Ž ϻ Ž + for (int i = 0; i < 4; i++) { + int a2 = a + x[i]; + int b2 = b + y[i]; + if (a2 >= 0 && a2 < siz && b2 >= 0 && b2 < siz && !visited[a2][b2]&&color[a][b]==color[a2][b2]) { + visited[a2][b2] = true; + dfs(a2, b2,color,visited); + } + } +} +int main(void) { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cin >> siz; + for (int i = 0; i < siz; i++) { //color,clolor2迭 ׸ Է¹޾ ش. + cin >> line; + for (int j = 0; j < siz; j++) { + color[i][j] = line[j]; + if (line[j] == 'R') color2[i][j] = 'G'; //ϻ r g ٲ㼭 ش. + else color2[i][j] = line[j]; + } + } + + for (int i = 0; i < siz; i++) { // Ž + for (int j = 0; j < siz; j++) { + if (!visited[i][j]) { + dfs(i,j,color,visited); + coun++; + } + } + } + for (int i = 0; i < siz; i++) { //ϻ Ž + for (int j = 0; j < siz; j++) { + if (!visited2[i][j]) { + dfs(i, j, color2,visited2); + coun2++; + } + } + } + cout << coun <<" "<< coun2; + return 0; +} \ No newline at end of file From 427367c902c4fdcfabdb2a3e9dd470a9c6e1da5c Mon Sep 17 00:00:00 2001 From: InSange Date: Fri, 12 Apr 2024 16:58:20 +0900 Subject: [PATCH 12/24] 2024-04-12 Top K Frequent Words --- InSange/README.md | 3 +- .../\355\236\231/Top K Frequent Words.cpp" | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 "InSange/\355\236\231/Top K Frequent Words.cpp" diff --git a/InSange/README.md b/InSange/README.md index 0960f73..bb80ee4 100644 --- a/InSange/README.md +++ b/InSange/README.md @@ -9,6 +9,7 @@ | 5차시 | 2024.03.27 | DP | [RGB거리2](https://www.acmicpc.net/problem/17404) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)] | 6차시 | 2024.04.01 | 최소신장트리 | [행성 터널](https://www.acmicpc.net/problem/2887) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/24)] | 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] -| 8차시 | 2024.04.09 | 투 포인터 | [두 용액](https://www.acmicpc.net/problem/2470) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] +| 8차시 | 2024.04.09 | 투 포인터 | [두 용액](https://www.acmicpc.net/problem/2470) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/32)] +| 9차시 | 2024.04.12 | 힙 | [Top K Frequent Words](https://leetcode.com/submissions/detail/1180988760/) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] ======= --- diff --git "a/InSange/\355\236\231/Top K Frequent Words.cpp" "b/InSange/\355\236\231/Top K Frequent Words.cpp" new file mode 100644 index 0000000..c823ef2 --- /dev/null +++ "b/InSange/\355\236\231/Top K Frequent Words.cpp" @@ -0,0 +1,34 @@ +#include +#include +#include +#include + +using namespace std; + +class Solution { +public: + struct compare { + bool operator()(pair& a, pair& b) + { + if (a.first == b.first) return a.second > b.second; + return a.first < b.first; + } + }; + + vector topKFrequent(vector& words, int k) { + unordered_map um; + priority_queue, vector>, compare> pq; + vector ans; + + for (auto s : words) um[s]++; + for (pair v : um) pq.push({ v.second, v.first }); + + while (k--) + { + ans.push_back(pq.top().second); + pq.pop(); + } + + return ans; + } +}; \ No newline at end of file From 659a779bf666082ecad950c6947975fa2ebf731a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=A0=EC=9A=B0?= <51250442+InSange@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:28:27 +0900 Subject: [PATCH 13/24] 9-InSange --- InSange/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InSange/README.md b/InSange/README.md index bb80ee4..8af9c3a 100644 --- a/InSange/README.md +++ b/InSange/README.md @@ -10,6 +10,6 @@ | 6차시 | 2024.04.01 | 최소신장트리 | [행성 터널](https://www.acmicpc.net/problem/2887) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/24)] | 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] | 8차시 | 2024.04.09 | 투 포인터 | [두 용액](https://www.acmicpc.net/problem/2470) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/32)] -| 9차시 | 2024.04.12 | 힙 | [Top K Frequent Words](https://leetcode.com/submissions/detail/1180988760/) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] +| 9차시 | 2024.04.12 | 힙 | [Top K Frequent Words](https://leetcode.com/problems/top-k-frequent-words/) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/34)] ======= --- From 2af13495d8b41bfea8c29e12bfdfa6f603d7418e Mon Sep 17 00:00:00 2001 From: seongwon030 <105052068+seongwon030@users.noreply.github.com> Date: Fri, 12 Apr 2024 20:47:11 +0900 Subject: [PATCH 14/24] =?UTF-8?q?2024-04-12=20=EA=B2=B0=ED=98=BC=EC=8B=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\352\262\260\355\230\274\354\213\235.py" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "seongwon030/bfs/\352\262\260\355\230\274\354\213\235.py" diff --git "a/seongwon030/bfs/\352\262\260\355\230\274\354\213\235.py" "b/seongwon030/bfs/\352\262\260\355\230\274\354\213\235.py" new file mode 100644 index 0000000..9779c02 --- /dev/null +++ "b/seongwon030/bfs/\352\262\260\355\230\274\354\213\235.py" @@ -0,0 +1,32 @@ +from collections import deque +import sys + +input = sys.stdin.readline + +n = int(input()) +m = int(input()) +arr = [[0 for i in range(n)] for i in range(n)] + +for i in range(m): + a,b = map(int,input().split()) + arr[a-1][b-1] = 1 # 노드 저장 + arr[b-1][a-1] = 1 +visited = [0 for i in range(len(arr))] + +def bfs(start): + q = deque() + q.append(start) + visited[start] = 1 + while q: + top = q.popleft() + for i in range(len(arr)): + if arr[top][i] == 1 and visited[i] == 0: + visited[i] = visited[top]+1 + q.append(i) + +bfs(0) +re = 0 +for i in visited: + if i==2 or i==3: + re+=1 +print(re) \ No newline at end of file From 1bbd5e265ce7d2e21478e0d42abf33efbbb1fd0d Mon Sep 17 00:00:00 2001 From: yuyu0830 Date: Fri, 12 Apr 2024 23:34:11 +0900 Subject: [PATCH 15/24] =?UTF-8?q?24/04/12=20=EC=95=8C=EA=B3=A0=EB=A6=AC?= =?UTF-8?q?=EC=A6=98=20=EC=88=98=EC=97=85=20-=20=EB=B2=84=EB=B8=94=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "yuyu0830/\354\240\225\353\240\254/23970.cpp" | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 "yuyu0830/\354\240\225\353\240\254/23970.cpp" diff --git "a/yuyu0830/\354\240\225\353\240\254/23970.cpp" "b/yuyu0830/\354\240\225\353\240\254/23970.cpp" new file mode 100644 index 0000000..c7120c1 --- /dev/null +++ "b/yuyu0830/\354\240\225\353\240\254/23970.cpp" @@ -0,0 +1,58 @@ +#include + +#define fastio cin.tie(NULL); cin.sync_with_stdio(false); + +using namespace std; + +int arr[2][10001] = {0, }; +int n, arrPtr = 0; + +bool same() { + // start at 'arrPtr' + for (int i = arrPtr; i < n; i++) { + // if diff, terminate this function + if (arr[0][i] != arr[1][i]) return false; + // if same, then that index will same forever. no reason to compare again. + arrPtr++; + } + return true; +} + +int main() { + fastio + cin >> n; + for (int i = 0; i < 2; i++) + for (int j = 0; j < n; j++) + cin >> arr[i][j]; + + int rnd = n - 1, ptr = 0; + + // it can be same before sort + if (same()) { + printf("1\n"); + return 0; + } + + while (rnd) { + // sort [0] to [ptr - rnd] + int a = arr[0][ptr]; + int b = arr[0][ptr + 1]; + + arr[0][ptr] = min(a, b); + arr[0][ptr + 1] = max(a, b); + + // if this index is last index in this round + if (++ptr == rnd) { + // next round + ptr = 0; + rnd--; + } + + if (same()) { + // if arr is same + printf("1\n"); + return 0; + } + } + printf("0\n"); +} \ No newline at end of file From a5c3f7e19528d73e771cbee589153234a2df7bf0 Mon Sep 17 00:00:00 2001 From: seongwon030 <105052068+seongwon030@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:29:22 +0900 Subject: [PATCH 16/24] =?UTF-8?q?2024-4-29=201,2,3=20=EB=8D=94=ED=95=98?= =?UTF-8?q?=EA=B8=B03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1,2,3 \353\215\224\355\225\230\352\270\2603.py" | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 "seongwon030/DP/1,2,3 \353\215\224\355\225\230\352\270\2603.py" diff --git "a/seongwon030/DP/1,2,3 \353\215\224\355\225\230\352\270\2603.py" "b/seongwon030/DP/1,2,3 \353\215\224\355\225\230\352\270\2603.py" new file mode 100644 index 0000000..a891a28 --- /dev/null +++ "b/seongwon030/DP/1,2,3 \353\215\224\355\225\230\352\270\2603.py" @@ -0,0 +1,11 @@ +import sys + +input = sys.stdin.readline +dp = [1,2,4,7] +p = 4 +for i in range(int(input())): + n = int(input()) + while(n>p): + dp.append((dp[p-3]+dp[p-2]+dp[p-1])%1000000009) + p+=1 + print(dp[n-1]) \ No newline at end of file From 7c8e86984878878bf546deb4a6fc0132159a5806 Mon Sep 17 00:00:00 2001 From: InSange Date: Thu, 2 May 2024 00:26:41 +0900 Subject: [PATCH 17/24] =?UTF-8?q?24-05-02=20=EC=98=A4=EC=95=84=EC=8B=9C?= =?UTF-8?q?=EC=8A=A4=20=EC=9E=AC=EA=B2=B0=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- InSange/README.md | 1 + "InSange/\354\212\244\355\203\235/3015.cpp" | 62 +++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 "InSange/\354\212\244\355\203\235/3015.cpp" diff --git a/InSange/README.md b/InSange/README.md index bb80ee4..1542bc2 100644 --- a/InSange/README.md +++ b/InSange/README.md @@ -11,5 +11,6 @@ | 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] | 8차시 | 2024.04.09 | 투 포인터 | [두 용액](https://www.acmicpc.net/problem/2470) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/32)] | 9차시 | 2024.04.12 | 힙 | [Top K Frequent Words](https://leetcode.com/submissions/detail/1180988760/) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] +| 10차시 | 2024.05.02 | 스택 | [Top K Frequent Words](https://leetcode.com/submissions/detail/1180988760/) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] ======= --- diff --git "a/InSange/\354\212\244\355\203\235/3015.cpp" "b/InSange/\354\212\244\355\203\235/3015.cpp" new file mode 100644 index 0000000..b693d73 --- /dev/null +++ "b/InSange/\354\212\244\355\203\235/3015.cpp" @@ -0,0 +1,62 @@ +#include +#include +#include + +using namespace std; + +long long N, n, a, b, answer; +vector line; +stack> st; + +// a1 b ũ +// a1 b ۴ٸ b +void Solve() +{ + cin >> N; + + for (int i = 0; i < N; i++) + { + cin >> n; + line.push_back(n); + } + + for (auto num : line) + { + int cnt = 1; + + while (!st.empty()) + { + int cur = st.top().first; + int cur_cnt = st.top().second; + if (cur < num) + { + answer+= cur_cnt; + } + else if (cur == num) + { + answer += cur_cnt; + cnt += cur_cnt; + } + else //if(st.top().first > num) + { + answer++; + break; + } + st.pop(); + } + //cout << num << ", " << answer << "\n"; + st.push({num, cnt}); + } + + cout << answer; +} + +int main() +{ + cin.tie(nullptr); + ios::sync_with_stdio(false); + + Solve(); + + return 0; +} \ No newline at end of file From dbb1edb41aa504214a44ea55927db7dcc37d6b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=A0=EC=9A=B0?= <51250442+InSange@users.noreply.github.com> Date: Thu, 2 May 2024 01:56:08 +0900 Subject: [PATCH 18/24] 10-InSange --- InSange/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InSange/README.md b/InSange/README.md index 1542bc2..b4aad18 100644 --- a/InSange/README.md +++ b/InSange/README.md @@ -11,6 +11,6 @@ | 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] | 8차시 | 2024.04.09 | 투 포인터 | [두 용액](https://www.acmicpc.net/problem/2470) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/32)] | 9차시 | 2024.04.12 | 힙 | [Top K Frequent Words](https://leetcode.com/submissions/detail/1180988760/) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] -| 10차시 | 2024.05.02 | 스택 | [Top K Frequent Words](https://leetcode.com/submissions/detail/1180988760/) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] +| 10차시 | 2024.05.02 | 스택 | [오아시스 재결합](https://www.acmicpc.net/problem/3015) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/40)] ======= --- From 431d677073e739362b9183c966795ffe65adb356 Mon Sep 17 00:00:00 2001 From: InSange Date: Fri, 3 May 2024 13:34:04 +0900 Subject: [PATCH 19/24] =?UTF-8?q?2024-05-03=20=EC=88=AB=EC=9E=90=20?= =?UTF-8?q?=EA=B3=A0=EB=A5=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- InSange/DFS/2668.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++ InSange/README.md | 3 ++- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 InSange/DFS/2668.cpp diff --git a/InSange/DFS/2668.cpp b/InSange/DFS/2668.cpp new file mode 100644 index 0000000..e6ea5a5 --- /dev/null +++ b/InSange/DFS/2668.cpp @@ -0,0 +1,60 @@ +#include +#include +#include + +using namespace std; + +int N, num; +vector visited; +vector v; +vector answer; + +void DFS(int cur, int start) +{ + if (visited[cur] == true) + { + if (start == cur) answer.push_back(start); + return; + } + + visited[cur] = true; + DFS(v[cur], start); + visited[cur] = false; +} + +void Solve() +{ + cin >> N; + + N += 1; + visited.assign(N, false); + v.assign(N, 0); + + for (int i = 1; i < N; i++) + { + cin >> v[i]; + } + + for (int i = 1; i < N; i++) + { + DFS(i, i); + } + + int asize = answer.size(); + cout << asize << "\n"; + + for (int i = 0; i < asize; i++) + { + cout << answer[i] << "\n"; + } +} + +int main() +{ + cin.tie(nullptr); + ios::sync_with_stdio(false); + + Solve(); + + return 0; +} \ No newline at end of file diff --git a/InSange/README.md b/InSange/README.md index 1542bc2..854679e 100644 --- a/InSange/README.md +++ b/InSange/README.md @@ -11,6 +11,7 @@ | 7차시 | 2024.04.04 | 스택 | [문자열 폭발](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] | 8차시 | 2024.04.09 | 투 포인터 | [두 용액](https://www.acmicpc.net/problem/2470) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/32)] | 9차시 | 2024.04.12 | 힙 | [Top K Frequent Words](https://leetcode.com/submissions/detail/1180988760/) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] -| 10차시 | 2024.05.02 | 스택 | [Top K Frequent Words](https://leetcode.com/submissions/detail/1180988760/) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] +| 10차시 | 2024.05.02 | 스택 | [오아시스 재결합](https://www.acmicpc.net/problem/3015) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/40)] +| 11차시 | 2024.05.02 | DFS | [숫자고르기](https://www.acmicpc.net/problem/2668) | [#11](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] ======= --- From e3ff94d6c52daefaad8f00a0144c5bc526aa2b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=A0=EC=9A=B0?= <51250442+InSange@users.noreply.github.com> Date: Fri, 3 May 2024 14:01:28 +0900 Subject: [PATCH 20/24] 11-InSange --- InSange/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InSange/README.md b/InSange/README.md index 854679e..0828da4 100644 --- a/InSange/README.md +++ b/InSange/README.md @@ -12,6 +12,6 @@ | 8차시 | 2024.04.09 | 투 포인터 | [두 용액](https://www.acmicpc.net/problem/2470) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/32)] | 9차시 | 2024.04.12 | 힙 | [Top K Frequent Words](https://leetcode.com/submissions/detail/1180988760/) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] | 10차시 | 2024.05.02 | 스택 | [오아시스 재결합](https://www.acmicpc.net/problem/3015) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/40)] -| 11차시 | 2024.05.02 | DFS | [숫자고르기](https://www.acmicpc.net/problem/2668) | [#11](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)] +| 11차시 | 2024.05.02 | DFS | [숫자고르기](https://www.acmicpc.net/problem/2668) | [#11](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/41)] ======= --- From f49b42035572ea064c8994c12dd2a50887c4476c Mon Sep 17 00:00:00 2001 From: dhlee777 Date: Mon, 6 May 2024 01:23:11 +0900 Subject: [PATCH 21/24] 2024-05-06 AC --- .../AC.cpp" | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 "dhlee777/\353\254\270\354\236\220\354\227\264\354\262\230\353\246\254/AC.cpp" diff --git "a/dhlee777/\353\254\270\354\236\220\354\227\264\354\262\230\353\246\254/AC.cpp" "b/dhlee777/\353\254\270\354\236\220\354\227\264\354\262\230\353\246\254/AC.cpp" new file mode 100644 index 0000000..55ed379 --- /dev/null +++ "b/dhlee777/\353\254\270\354\236\220\354\227\264\354\262\230\353\246\254/AC.cpp" @@ -0,0 +1,86 @@ +#include +#include +#include +#include +using namespace std; +vectorv; //迭 ҵ +string a,b,nm; //a-ɾ string, b-迭 string +int main(void) { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int t,num,start_idx,end_idx; //t-׽Ʈ̽,num-ǰ,start_idx- ε,end_idx-ε + int r_cnt = 0; + cin >> t; + while (t--) { + cin >> a>>num>>b; + start_idx = 0; end_idx = num - 1; + r_cnt = 0; + for (int i = 0; i end_idx) + start_idx--; + else if (end_idx > start_idx) + start_idx++; + else end_idx = -1; //ε ε 쿡 Ҵ ϳϹǷ d Ұ Ͱ Եȴ. + r_cnt = 0; + } + } + if (r_cnt != 0 && end_idx > -1&&r_cnt%2==1) { //ϳ r ð Ͱ ƴϰ rǰ Ȧ϶ + int temp = start_idx; + start_idx = end_idx; + end_idx = temp; + } + + if (end_idx == -2) cout << "error"<<"\n"; + else if (end_idx == -1) cout << "[]"<<"\n"; + else { + cout << "["; + if (start_idx >= end_idx) { + for (int i =start_idx; i>end_idx; i--) { + cout << v[i] << ","; + } + cout << v[end_idx]<<"]"<<"\n"; + } + else { + for (int i = start_idx; i < end_idx; i++) { + cout << v[i] << ","; + } + cout << v[end_idx]<<"]"<<"\n"; + } + + } + + vector().swap(v); //ٸ ׽Ʈ̽ ʱȭ + + } + + +} \ No newline at end of file From 06f49c9684219aedfc5adaf5dd9159f063b3eb05 Mon Sep 17 00:00:00 2001 From: seongwon030 <105052068+seongwon030@users.noreply.github.com> Date: Tue, 7 May 2024 00:46:25 +0900 Subject: [PATCH 22/24] =?UTF-8?q?2024-05-07=202737=20=EC=97=B0=EC=86=8D?= =?UTF-8?q?=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\227\260\354\206\215 \355\225\251.py" | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 "seongwon030/\354\210\230\355\225\231/\354\227\260\354\206\215 \355\225\251.py" diff --git "a/seongwon030/\354\210\230\355\225\231/\354\227\260\354\206\215 \355\225\251.py" "b/seongwon030/\354\210\230\355\225\231/\354\227\260\354\206\215 \355\225\251.py" new file mode 100644 index 0000000..d931227 --- /dev/null +++ "b/seongwon030/\354\210\230\355\225\231/\354\227\260\354\206\215 \355\225\251.py" @@ -0,0 +1,20 @@ +import math + +n = int(input()) +for i in range(n): + cnt = 0 + k = int(input()) + j = 2 # 적어도 2개 이상의 연속된 자연수의 합 + while True: + center_first = math.floor(k / j) # center 값을 초기화 + div = j // 2 + if center_first < div: + break + if j % 2 == 0: + if ((center_first + center_first + 1) * div == k): + cnt += 1 + elif j % 2 == 1: + if ((center_first * 2 * div + center_first) == k): + cnt += 1 + j += 1 + print(cnt) From 19c275d1e0802c192d43ac920358a37ba1b1ebdb Mon Sep 17 00:00:00 2001 From: seongwon030 <105052068+seongwon030@users.noreply.github.com> Date: Tue, 7 May 2024 17:26:53 +0900 Subject: [PATCH 23/24] =?UTF-8?q?2024-05-07=202225=20=ED=95=A9=EB=B6=84?= =?UTF-8?q?=ED=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DP/\355\225\251\353\266\204\355\225\264.py" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "seongwon030/DP/\355\225\251\353\266\204\355\225\264.py" diff --git "a/seongwon030/DP/\355\225\251\353\266\204\355\225\264.py" "b/seongwon030/DP/\355\225\251\353\266\204\355\225\264.py" new file mode 100644 index 0000000..13e1241 --- /dev/null +++ "b/seongwon030/DP/\355\225\251\353\266\204\355\225\264.py" @@ -0,0 +1,13 @@ +n,k = map(int,input().split()) + +mod = 1000000000 + +dp = [[0] * (n+1) for _ in range(k+1)] # 2차원 배열 +dp [0][0] = 1 # 초기값 설정 + +for i in range(1,k+1): + for j in range(n+1): + dp[i][j] = dp[i-1][j] + dp[i][j-1] + dp[i][j] = dp[i][j] % mod + +print(dp[k][n]) \ No newline at end of file From 1d687ded14aa0b331ac47550cec15b93d8e3dbbb Mon Sep 17 00:00:00 2001 From: dhlee777 Date: Fri, 10 May 2024 17:34:15 +0900 Subject: [PATCH 24/24] =?UTF-8?q?2024-05-10=20=ED=86=A0=EB=A7=88=ED=86=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\355\206\240\353\247\210\355\206\240.cpp" | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 "dhlee777/bfs/\355\206\240\353\247\210\355\206\240.cpp" diff --git "a/dhlee777/bfs/\355\206\240\353\247\210\355\206\240.cpp" "b/dhlee777/bfs/\355\206\240\353\247\210\355\206\240.cpp" new file mode 100644 index 0000000..8b67176 --- /dev/null +++ "b/dhlee777/bfs/\355\206\240\353\247\210\355\206\240.cpp" @@ -0,0 +1,71 @@ +#include +#include +using namespace std; +int tom[101][101][101]; //丶 ¸ ϱ 迭 +int col, row, height; +int x[6] = { 0,0,-1,1,0,0 }; +int y[6] = { -1,1,0,0,0,0 }; +int z[6] = { 0,0,0,0,1,-1 }; +struct tomato { //丶 ǥ ϱ ü + int x1; // + int y1; // + int z1; // + tomato(int _x1, int _y1, int _z1) { + x1 = _x1; y1 = _y1; z1 = _z1; + + } +}; +queueq; +void bfs() { + while (!q.empty()) { + tomato t = q.front(); + q.pop(); + for (int i = 0; i < 6; i++) { //Ž(,,,,,Ʒ) + int _x = t.x1 + x[i]; + int _y = t.y1 + y[i]; + int _z = t.z1 + z[i]; + if (_x < col && _x >= 0 && _y < row && _y >= 0 && _z < height && _z >= 0 && tom[_z][_y][_x] == 0) { + tom[_z][_y][_x] = tom[t.z1][t.y1][t.x1] + 1; + q.push(tomato(_x, _y, _z)); + + } + } + + + } + +} +int main(void) { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cin >> col >> row >> height; + + for (int i = 0; i < height; i++) { + for (int j = 0; j < row; j++) { + for (int k = 0; k < col; k++) { + cin >> tom[i][j][k]; + if (tom[i][j][k] == 1) //丶䰡 + q.push(tomato(k, j, i)); //Ž ǥ ť ִ´. + } + } + } + + bfs(); // + int sum = 0; + for (int i = 0; i < height; i++) { + for (int j = 0; j < row; j++) { + for (int k = 0; k < col; k++) { + if (tom[i][j][k] == 0) //bfs 丶䰡 ִٸ ϴ Ȳ̹Ƿ -1 + { + cout << -1; + return 0; + } + if (sum < tom[i][j][k]) sum = tom[i][j][k]; //bfs ɸð ã tom迭 ִ밪 ã sum ϴ° + + } + } + } + + sum == 1 ? cout << 0 : cout << sum - 1; + +} \ No newline at end of file