Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

11-g0rnn #49

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store
.idea/
/.vscode
cmake-build-debug/
CMakeLists.txt
24 changes: 13 additions & 11 deletions g0rnn/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
## โœ๏ธ ๊ธฐ๋ก

| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
| :---: | :--------: | :--------: | :---------------------------------------------------------------------------: | :-------------------------------------------------: |
| 1์ฐจ์‹œ | 2024.10.01 | ๊ตฌํ˜„ | [์ถ”์–ต ์ ์ˆ˜](https://school.programmers.co.kr/learn/courses/30/lessons/176963) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/35 |
| 2์ฐจ์‹œ | 2024.10.03 | ํŠธ๋ฆฌ | [LCA2](https://school.programmers.co.kr/learn/courses/30/lessons/176963) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/7 |
| 3์ฐจ์‹œ | 2024.10.04 | ๋ฌธ์ž์—ด | [์žƒ์–ด๋ฒ„๋ฆฐ ๊ด„ํ˜ธ](https://www.acmicpc.net/problem/1541) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/9 |
| 4์ฐจ์‹œ | 2024.10.11 | ๋ธŒ๋ฃจํŠธํฌ์Šค | [์˜ํ™”๊ฐ๋… ์ˆŒ](https://www.acmicpc.net/problem/1436) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/15 |
| 5์ฐจ์‹œ | 2024.11.01 | BFS/DFS | [์—ฐ๊ตฌ์†Œ](https://www.acmicpc.net/problem/14502) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/17 |
| 6์ฐจ์‹œ | 2024.11.06 | ๊ตฌํ˜„ | [ํ†ต๊ณ„ํ•™](https://www.acmicpc.net/problem/2108) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/23 |
| 7์ฐจ์‹œ | 2024.11.25 | ๊ตฌํ˜„ | [ํŒฐ๋ฆฐ๋“œ๋กฌ ๋งŒ๋“ค๊ธฐ](https://www.acmicpc.net/problem/1213) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/31 |
| 8์ฐจ์‹œ | 2024.11.29 | ๋ฌธ์ž์—ด | [์ž ์ˆ˜ํ•จ์‹๋ณ„](https://www.acmicpc.net/problem/2671) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/35 |
| 9์ฐจ์‹œ | 2024.12.04 | ๊ทธ๋ฆฌ๋”” | [A->B](https://www.acmicpc.net/problem/16953) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/39 |
| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
|:----:|:----------:|:-------:|:-------------------------------------------------------------------------:|:---------------------------------------------------:|
| 1์ฐจ์‹œ | 2024.10.01 | ๊ตฌํ˜„ | [์ถ”์–ต ์ ์ˆ˜](https://school.programmers.co.kr/learn/courses/30/lessons/176963) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/35 |
| 2์ฐจ์‹œ | 2024.10.03 | ํŠธ๋ฆฌ | [LCA2](https://school.programmers.co.kr/learn/courses/30/lessons/176963) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/7 |
| 3์ฐจ์‹œ | 2024.10.04 | ๋ฌธ์ž์—ด | [์žƒ์–ด๋ฒ„๋ฆฐ ๊ด„ํ˜ธ](https://www.acmicpc.net/problem/1541) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/9 |
| 4์ฐจ์‹œ | 2024.10.11 | ๋ธŒ๋ฃจํŠธํฌ์Šค | [์˜ํ™”๊ฐ๋… ์ˆŒ](https://www.acmicpc.net/problem/1436) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/15 |
| 5์ฐจ์‹œ | 2024.11.01 | BFS/DFS | [์—ฐ๊ตฌ์†Œ](https://www.acmicpc.net/problem/14502) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/17 |
| 6์ฐจ์‹œ | 2024.11.06 | ๊ตฌํ˜„ | [ํ†ต๊ณ„ํ•™](https://www.acmicpc.net/problem/2108) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/23 |
| 7์ฐจ์‹œ | 2024.11.25 | ๊ตฌํ˜„ | [ํŒฐ๋ฆฐ๋“œ๋กฌ ๋งŒ๋“ค๊ธฐ](https://www.acmicpc.net/problem/1213) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/31 |
| 8์ฐจ์‹œ | 2024.11.29 | ๋ฌธ์ž์—ด | [์ž ์ˆ˜ํ•จ์‹๋ณ„](https://www.acmicpc.net/problem/2671) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/35 |
| 9์ฐจ์‹œ | 2024.12.04 | ๊ทธ๋ฆฌ๋”” | [A->B](https://www.acmicpc.net/problem/16953) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/39 |
| 10์ฐจ์‹œ | 2024.12.20 | ๊ทธ๋ž˜ํ”„ | [๊ฒฐํ˜ผ์‹](https://www.acmicpc.net/problem/5567) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/40 |
| 11์ฐจ์‹œ | 2024.12.30 | dp | [๊ธฐํƒ€๋ฆฌ์ŠคํŠธ](https://www.acmicpc.net/problem/1495) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/49 |

---
38 changes: 38 additions & 0 deletions g0rnn/dp/11-g0rnn.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Created by ๊น€๊ท ํ˜ธ on 2024. 12. 31..
//
// 1. ์กฐ์ ˆํ•œ ๋ณผ๋ฅจ์ด 0๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ max๋ณด๋‹ค ํฌ๋ฉด ์—ฐ์ฃผํ•  ์ˆ˜ ์—†๋‹ค -> -1
// 2. ๋ฒ”์œ„ ๋‚ด์˜ ์ตœ๋Œ“๊ฐ’์„ ๊ตฌํ•˜๋ผ

#include <iostream>
using namespace std;

int n, s, m;
int v[55];
bool dp[55][1005];
int ans = -1;

int main() {
cin >> n >> s >> m;
for (int i = 1; i <= n; i++)
cin >> v[i];

if (s + v[1] <= m) dp[1][s + v[1]] = true;
if (s - v[1] >= 0) dp[1][s - v[1]] = true;

for (int i = 2; i <= n; i++) {
for (int j = 0; j <= m; j++) {
if (!dp[i - 1][j]) continue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด๋ ‡๊ฒŒ ํ•˜๋‹ˆ๊นŒ ๊น”๋”ํ•˜๊ณ  ์ข‹๋„ค์š” ๐Ÿ‘

if (j + v[i] <= m) dp[i][j + v[i]] = true;
if (j - v[i] >= 0) dp[i][j - v[i]] = true;
}
}
for (int i = m; i >= 0; i--) {
if (dp[n][i]) {
ans = i;
break;
}
}
cout << ans;
return 0;
}
38 changes: 38 additions & 0 deletions g0rnn/graph/10-g0rnn.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Created by ๊น€๊ท ํ˜ธ on 2024. 12. 20..
//
#include <iostream>
#include <unordered_set>
#include <vector>
using namespace std;

const int SANG = 1;
int n, m;
int ret = 0;
vector<unordered_set<int> > relationship;
unordered_set<int> members = {1};

int main() {
cin >> n >> m;
relationship = vector<unordered_set<int> >(n + 1);
int a, b;

for (int i = 0; i < m; i++) {
cin >> a >> b;
//
if (a == SANG) members.insert(b);
// make a graph
relationship[a].insert(b);
relationship[b].insert(a);
}

// find friends' friends
for (auto f: relationship[SANG]) {
for (auto r: relationship[f]) {
members.insert(r);
}
}

// exclude SANG
cout << members.size() - 1;
}
Loading