From e76405160a11d42b1c5889d703e54ee588557eb1 Mon Sep 17 00:00:00 2001 From: Junseo Kim Date: Sat, 13 Apr 2024 02:24:59 +0900 Subject: [PATCH 1/5] =?UTF-8?q?2024-04-13=20=EB=93=A3=EB=B3=B4=EC=9E=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oesnuj/README.md | 1 + .../1764.cpp" | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 "oesnuj/\354\235\264\353\266\204\355\203\220\354\203\211/1764.cpp" diff --git a/oesnuj/README.md b/oesnuj/README.md index e5d0c1f..a1d5c67 100644 --- a/oesnuj/README.md +++ b/oesnuj/README.md @@ -6,4 +6,5 @@ | 2차시 | 2024.03.29 | 연결리스트 | [에디터](https://www.acmicpc.net/problem/1406) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/8) | | 3차시 | 2024.04.02 | 덱 | [카드 놓기](https://www.acmicpc.net/problem/18115) | [#11](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/11) | | 4차시 | 2024.04.06 | 스택 | [옥상 정원 꾸미기](https://www.acmicpc.net/problem/6198) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/14) | +| 5차시 | 2024.04.13 | 이분탐색 | [듣보잡](https://www.acmicpc.net/problem/1764) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/20) | --- diff --git "a/oesnuj/\354\235\264\353\266\204\355\203\220\354\203\211/1764.cpp" "b/oesnuj/\354\235\264\353\266\204\355\203\220\354\203\211/1764.cpp" new file mode 100644 index 0000000..370a4f5 --- /dev/null +++ "b/oesnuj/\354\235\264\353\266\204\355\203\220\354\203\211/1764.cpp" @@ -0,0 +1,53 @@ +#include +#include +#include +#include +using namespace std; + + +bool binarySearch(vector &v, string str) //이분탐색 +{ + int left = 0; + int right = v.size() - 1; + while (left <= right) + { + int middle = (left + right) / 2; + if (str > v[middle]) + left = middle + 1; + else if (str < v[middle]) + right = middle - 1; + else + return true; + + } + return false; +} + + +int main() +{ + ios_base::sync_with_stdio(false); cin.tie(NULL); + int n, m; + cin >> n >> m; + vector v(n); //듣도 못한 사람 입력 + for (auto& i : v){ + cin >> i; + } + sort(v.begin(), v.end()); //이분 탐색을 위해 정렬 + vector result; + for (int i = 0; i < m; i++) + { + string word; + cin >> word; //보도 못한 사람 입력 + if (binarySearch(v, word)){ //보도 못한 사람이 듣도 보다 못한 사람에도 포함되면 + result.push_back(word); + } + } + sort(result.begin(), result.end()); //마지막 사전순 정렬을 위해 정렬 + + cout << result.size() << "\n"; + for (const auto& word : result) { + cout << word << "\n"; + } + return 0; +} \ No newline at end of file From 41430fe15bec0e9cca32556a10a3db87cabe93ab Mon Sep 17 00:00:00 2001 From: Junseo Kim Date: Mon, 6 May 2024 06:29:23 +0900 Subject: [PATCH 2/5] =?UTF-8?q?2024-05-06=20=EC=A0=95=EC=82=AC=EA=B0=81?= =?UTF-8?q?=ED=98=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oesnuj/README.md | 1 + "oesnuj/\352\270\260\355\225\230/1485.cpp" | 53 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 "oesnuj/\352\270\260\355\225\230/1485.cpp" diff --git a/oesnuj/README.md b/oesnuj/README.md index a1d5c67..5e5ddb8 100644 --- a/oesnuj/README.md +++ b/oesnuj/README.md @@ -7,4 +7,5 @@ | 3차시 | 2024.04.02 | 덱 | [카드 놓기](https://www.acmicpc.net/problem/18115) | [#11](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/11) | | 4차시 | 2024.04.06 | 스택 | [옥상 정원 꾸미기](https://www.acmicpc.net/problem/6198) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/14) | | 5차시 | 2024.04.13 | 이분탐색 | [듣보잡](https://www.acmicpc.net/problem/1764) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/20) | +| 6차시 | 2024.05.06 | 기하학 | [정사각형](https://www.acmicpc.net/problem/1485) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/22) | --- diff --git "a/oesnuj/\352\270\260\355\225\230/1485.cpp" "b/oesnuj/\352\270\260\355\225\230/1485.cpp" new file mode 100644 index 0000000..b795e78 --- /dev/null +++ "b/oesnuj/\352\270\260\355\225\230/1485.cpp" @@ -0,0 +1,53 @@ +#include +#include +#include +#include +using namespace std; + +struct Point +{ + int x, y; +}; + +int calcDistance(Point a, Point b) +{ + return pow(a.x - b.x, 2) + pow(a.y - b.y, 2); +} + +bool compareInfo(Point &a, Point &b) +{ + if(a.x == b.x) + return a.y < b.y; + return a.x < b.x; +} + +int main() { + ios::sync_with_stdio(false); + cin.tie(NULL); + + int n; + cin >> n; + + while (n--) + { + vector v(4); + for (int i = 0; i < 4; i++) { + cin >> v[i].x >> v[i].y; + } + sort(v.begin(), v.end(),compareInfo); + //2 3 + //0 1 + int s1 = calcDistance(v[0], v[1]); //선분 + int s2 = calcDistance(v[0], v[2]); + int s3 = calcDistance(v[1], v[3]); + int s4 = calcDistance(v[2], v[3]); + + int dia1 = calcDistance(v[0], v[3]); //대각선 + int dia2 = calcDistance(v[1], v[2]); + if (s1 == s2 && s2 == s3 && s3 == s4 && dia1 == dia2) //네변의 길이가 같고 대각선의 길이가 같다. + cout << 1 << '\n'; + else + cout << 0 << '\n'; + } + return 0; +} \ No newline at end of file From 5d67668853c523bb76202a7aa6e731724fae1fb2 Mon Sep 17 00:00:00 2001 From: Junseo Kim Date: Wed, 8 May 2024 02:00:32 +0900 Subject: [PATCH 3/5] 2024-05-08 queuestack --- oesnuj/README.md | 1 + "oesnuj/\353\215\261/24511.cpp" | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 "oesnuj/\353\215\261/24511.cpp" diff --git a/oesnuj/README.md b/oesnuj/README.md index 5e5ddb8..0c1da06 100644 --- a/oesnuj/README.md +++ b/oesnuj/README.md @@ -8,4 +8,5 @@ | 4차시 | 2024.04.06 | 스택 | [옥상 정원 꾸미기](https://www.acmicpc.net/problem/6198) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/14) | | 5차시 | 2024.04.13 | 이분탐색 | [듣보잡](https://www.acmicpc.net/problem/1764) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/20) | | 6차시 | 2024.05.06 | 기하학 | [정사각형](https://www.acmicpc.net/problem/1485) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/22) | +| 7차시 | 2024.05.08 | 스택, 큐, 덱 | [queuestack](https://www.acmicpc.net/problem/24511) | [#24](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/24) | --- diff --git "a/oesnuj/\353\215\261/24511.cpp" "b/oesnuj/\353\215\261/24511.cpp" new file mode 100644 index 0000000..1868b93 --- /dev/null +++ "b/oesnuj/\353\215\261/24511.cpp" @@ -0,0 +1,35 @@ +#include +#include +#include +using namespace std; + +int main() +{ + ios::sync_with_stdio(false); cin.tie(NULL); + int n; + cin >> n; + vector dataStructure(n); //스텍인지 큐인지 입력받기 + for (auto& i : dataStructure){ + cin >> i; + } + + deque queuestack; + for (int i = 0; i < n; i++) + { + int x; + cin >> x; + if (dataStructure.at(i) == 0) //큐인 경우에만 처리, 스택은 무조건 입력값이 나오기에 없다고 보면됨 + queuestack.push_back(x); + } + int m; + cin >> m; + for (int i = 0; i < m; i++) + { + int x; + cin >> x; + queuestack.push_front(x); + cout << queuestack.back() << " "; + queuestack.pop_back(); + } + return 0; +} From db333684c73bf9e95a7a457cfb8372655195d5a0 Mon Sep 17 00:00:00 2001 From: Junseo Kim Date: Mon, 13 May 2024 12:26:55 +0900 Subject: [PATCH 4/5] =?UTF-8?q?2024-05-13=20=EC=B9=B4=EB=93=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oesnuj/README.md | 1 + .../1715.cpp" | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 "oesnuj/\354\232\260\354\204\240\354\210\234\354\234\204 \355\201\220/1715.cpp" diff --git a/oesnuj/README.md b/oesnuj/README.md index 0c1da06..c49dc46 100644 --- a/oesnuj/README.md +++ b/oesnuj/README.md @@ -9,4 +9,5 @@ | 5차시 | 2024.04.13 | 이분탐색 | [듣보잡](https://www.acmicpc.net/problem/1764) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/20) | | 6차시 | 2024.05.06 | 기하학 | [정사각형](https://www.acmicpc.net/problem/1485) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/22) | | 7차시 | 2024.05.08 | 스택, 큐, 덱 | [queuestack](https://www.acmicpc.net/problem/24511) | [#24](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/24) | +| 8차시 | 2024.05.13 | 우선순위 큐 | [카드 정렬하기](https://www.acmicpc.net/problem/1715) | [#27](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/27) | --- diff --git "a/oesnuj/\354\232\260\354\204\240\354\210\234\354\234\204 \355\201\220/1715.cpp" "b/oesnuj/\354\232\260\354\204\240\354\210\234\354\234\204 \355\201\220/1715.cpp" new file mode 100644 index 0000000..7311750 --- /dev/null +++ "b/oesnuj/\354\232\260\354\204\240\354\210\234\354\234\204 \355\201\220/1715.cpp" @@ -0,0 +1,33 @@ +#include +#include + +using namespace std; + +int main() { + ios::sync_with_stdio(false); cin.tie(NULL); + + priority_queue , greater> pq; //최소 힙으로 우선순위 큐 선언 + int n; + cin >> n; + for (int i = 0; i < n; i++) //우선순위 큐에 다 넣음 + { + int x; + cin >> x; + pq.push(x); + } + int result = 0; + while(pq.size() > 1) //우선순위 큐에 값이 하나만 남을 때 까지 반복 + { + // 우선순위 큐에서 가장 작은 두 수를 꺼내서 합침 + int a = pq.top(); + pq.pop(); + int b = pq.top(); + pq.pop(); + int sum = a + b; + pq.push(sum); // 합친 결과를 우선순위 큐에 다시 넣음 + + result += sum; // 결과값을 누적 + } + cout << result; + return 0; +} \ No newline at end of file From d8f1ecc04ab860de057bf33f6bb015e7d993cb28 Mon Sep 17 00:00:00 2001 From: Junseo Kim Date: Thu, 30 May 2024 20:45:22 +0900 Subject: [PATCH 5/5] =?UTF-8?q?2024-05-30=20=EB=B9=99=EA=B3=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oesnuj/README.md | 1 + "oesnuj/\352\265\254\355\230\204/2578.cpp" | 79 ++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 "oesnuj/\352\265\254\355\230\204/2578.cpp" diff --git a/oesnuj/README.md b/oesnuj/README.md index c49dc46..f16f53f 100644 --- a/oesnuj/README.md +++ b/oesnuj/README.md @@ -10,4 +10,5 @@ | 6차시 | 2024.05.06 | 기하학 | [정사각형](https://www.acmicpc.net/problem/1485) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/22) | | 7차시 | 2024.05.08 | 스택, 큐, 덱 | [queuestack](https://www.acmicpc.net/problem/24511) | [#24](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/24) | | 8차시 | 2024.05.13 | 우선순위 큐 | [카드 정렬하기](https://www.acmicpc.net/problem/1715) | [#27](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/27) | +| 9차시 | 2024.05.30 | 구현 | [빙고](https://www.acmicpc.net/problem/2578) | [#30](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/30) | --- diff --git "a/oesnuj/\352\265\254\355\230\204/2578.cpp" "b/oesnuj/\352\265\254\355\230\204/2578.cpp" new file mode 100644 index 0000000..04b2adc --- /dev/null +++ "b/oesnuj/\352\265\254\355\230\204/2578.cpp" @@ -0,0 +1,79 @@ +#include +using namespace std; + +const int BINGO_SIZE = 5; +int board[BINGO_SIZE][BINGO_SIZE]; + +void changeBingo(int target); +int checkBingo(); + + + +int main() +{ + ios::sync_with_stdio(0); cin.tie(0); + for (int i = 0; i < BINGO_SIZE; i++) + { + for (int j = 0; j < BINGO_SIZE; j++) + { + cin >> board[i][j]; + } + } + + int sayCnt = 0; + for (int i = 0; i < BINGO_SIZE * BINGO_SIZE; i++) + { + int num; + cin >> num; + sayCnt++; + changeBingo(num); + if (checkBingo() >= 3) { + cout << sayCnt; + return 0; + } + } + return 0; +} + + +void changeBingo(int target) //사회자가 부른 수 체크하기 +{ + for (int i = 0; i < BINGO_SIZE; i++){ + for (int j = 0; j < BINGO_SIZE; j++){ + if (board[i][j] == target){ + board[i][j] = 0; + return; + } + } + } + return; +} + +int checkBingo() //현재 보드판에 빙고가 몇줄인지 +{ + int bingoCnt = 0; + + for (int i = 0; i < BINGO_SIZE; i++) //가로, 세로 빙고 확인 + { + int horizontal = 0, vertical = 0; + for (int j = 0; j < BINGO_SIZE; j++){ + if (!board[i][j]) + horizontal++; + if (!board[j][i]) + vertical++; + } + if (horizontal == BINGO_SIZE) bingoCnt++; + if (vertical == BINGO_SIZE) bingoCnt++; + } + + int right_diagonal = 0, left_diagonal = 0; + for (int i = 0; i < BINGO_SIZE; i++) //대각선 2개 빙고 확인 + { + if (!board[i][i]) right_diagonal++; + if (!board[i][BINGO_SIZE - i - 1]) left_diagonal++; + } + if (right_diagonal == BINGO_SIZE) bingoCnt++; + if (left_diagonal == BINGO_SIZE) bingoCnt++; + + return bingoCnt; +} \ No newline at end of file