From 173d65fdd3b7d348c6ad9fb0a41b366447eb7571 Mon Sep 17 00:00:00 2001 From: Shineast Date: Tue, 30 Apr 2024 11:25:48 +0900 Subject: [PATCH 01/19] =?UTF-8?q?[BOJ]=20=EB=B2=A0=EB=9D=BC=EC=9D=98=20?= =?UTF-8?q?=ED=8C=A8=EC=85=98=20/=20=EB=B8=8C=EB=A1=A0=EC=A6=88=204=20/=20?= =?UTF-8?q?1=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/15439 --- kangdy25/BOJ/15439.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 kangdy25/BOJ/15439.cpp diff --git a/kangdy25/BOJ/15439.cpp b/kangdy25/BOJ/15439.cpp new file mode 100644 index 000000000..778c32c64 --- /dev/null +++ b/kangdy25/BOJ/15439.cpp @@ -0,0 +1,13 @@ +// 베라의 패션 / 브론즈 4 +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N; + cin >> N; + + cout << N * (N - 1); +} \ No newline at end of file From bc054213ba08fdb7a4bc196c54e3dc78f04c566b Mon Sep 17 00:00:00 2001 From: Shineast Date: Tue, 30 Apr 2024 11:27:05 +0900 Subject: [PATCH 02/19] =?UTF-8?q?[BOJ]=20=EB=85=B9=EC=83=89=EA=B1=B0?= =?UTF-8?q?=ED=83=91=20/=20=EB=B8=8C=EB=A1=A0=EC=A6=884=20/=2010=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/24723 --- kangdy25/BOJ/24723.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 kangdy25/BOJ/24723.cpp diff --git a/kangdy25/BOJ/24723.cpp b/kangdy25/BOJ/24723.cpp new file mode 100644 index 000000000..add0d18cd --- /dev/null +++ b/kangdy25/BOJ/24723.cpp @@ -0,0 +1,16 @@ +// 녹색거탑 / 브론즈 4 +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N, result = 1; + cin >> N; + + for (int i = 1; i <= N; i++) { + result *= 2; + } + cout << result << "\n"; +} \ No newline at end of file From 8ddd4ea9b696fd3070f36e94416bac61e9c45bd5 Mon Sep 17 00:00:00 2001 From: Shineast Date: Tue, 30 Apr 2024 11:28:30 +0900 Subject: [PATCH 03/19] =?UTF-8?q?[BOJ]=20=ED=8C=A9=ED=86=A0=EB=A6=AC?= =?UTF-8?q?=EC=96=BC=20/=20=EB=B8=8C=EB=A1=A0=EC=A6=883=20/=204=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/10872 --- kangdy25/BOJ/10872.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 kangdy25/BOJ/10872.cpp diff --git a/kangdy25/BOJ/10872.cpp b/kangdy25/BOJ/10872.cpp new file mode 100644 index 000000000..516a921d1 --- /dev/null +++ b/kangdy25/BOJ/10872.cpp @@ -0,0 +1,15 @@ +// 팩토리얼 / 브론즈 3 +#include +using namespace std; + +int factorial(int n) { + if (n == 0) return 1; + else return n * factorial(n - 1); +} + +int main() { + int N; + cin >> N; + cout << factorial(N); + return 0; +} \ No newline at end of file From c4ee70dd06bb2158cab6ffc8de9a46012c95c558 Mon Sep 17 00:00:00 2001 From: Shineast Date: Tue, 30 Apr 2024 11:30:38 +0900 Subject: [PATCH 04/19] =?UTF-8?q?[BOJ]=20=EC=9D=B4=ED=95=AD=20=EA=B3=84?= =?UTF-8?q?=EC=88=98=201=20/=20=EB=B8=8C=EB=A1=A0=EC=A6=881=20/=207?= =?UTF-8?q?=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/11050 --- kangdy25/BOJ/11050.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 kangdy25/BOJ/11050.cpp diff --git a/kangdy25/BOJ/11050.cpp b/kangdy25/BOJ/11050.cpp new file mode 100644 index 000000000..90e022c33 --- /dev/null +++ b/kangdy25/BOJ/11050.cpp @@ -0,0 +1,25 @@ +// 이항 계수 1 / 브론즈 1 + +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N, K, result = 1; + cin >> N >> K; + int NK = N - K; + + + for (int i = N; i >= 1; i--) { + result *= i; + } + for (int j = K; j >= 1; j--) { + result /= j; + } + for (int j = NK; j >= 1; j--) { + result /= j; + } + cout << result << "\n"; +} \ No newline at end of file From 9518307d0927cfd2a0d4b80738a13d60d6ec933a Mon Sep 17 00:00:00 2001 From: Shineast Date: Tue, 30 Apr 2024 11:31:50 +0900 Subject: [PATCH 05/19] =?UTF-8?q?[BOJ]=20=EB=8B=A4=EB=A6=AC=20=EB=86=93?= =?UTF-8?q?=EA=B8=B0=20/=20=EC=8B=A4=EB=B2=845=20/=209=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/1010 --- kangdy25/BOJ/1010.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 kangdy25/BOJ/1010.cpp diff --git a/kangdy25/BOJ/1010.cpp b/kangdy25/BOJ/1010.cpp new file mode 100644 index 000000000..779042235 --- /dev/null +++ b/kangdy25/BOJ/1010.cpp @@ -0,0 +1,24 @@ +// 다리 놓기 / 실버 5 + +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N, K, result = 1; + cin >> N >> K; + int NK = N - K; + + for (int i = N; i >= 1; i--) { + result *= i; + } + for (int j = K; j >= 1; j--) { + result /= j; + } + for (int j = NK; j >= 1; j--) { + result /= j; + } + cout << result << "\n"; +} \ No newline at end of file From 189a05dfce7a6745dbb1e70edef15b310aa5111c Mon Sep 17 00:00:00 2001 From: Shineast Date: Tue, 30 Apr 2024 11:33:41 +0900 Subject: [PATCH 06/19] =?UTF-8?q?[BOJ]=20=ED=8C=A9=ED=86=A0=EB=A6=AC?= =?UTF-8?q?=EC=96=BC=202=20/=20=EB=B8=8C=EB=A1=A0=EC=A6=88=205=20/=2016?= =?UTF-8?q?=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/27433 --- kangdy25/BOJ/27433.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 kangdy25/BOJ/27433.cpp diff --git a/kangdy25/BOJ/27433.cpp b/kangdy25/BOJ/27433.cpp new file mode 100644 index 000000000..00e2c7865 --- /dev/null +++ b/kangdy25/BOJ/27433.cpp @@ -0,0 +1,22 @@ +// 팩토리얼 2 / 브론즈 5 + +#include +using namespace std; + +long long Factorial(long long a) { + if (a == 0 || a == 1) { + return 1; + } else { + return a * Factorial(a-1); + } +} + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + long long N; + cin >> N; + + cout << Factorial(N) << "\n"; +} From 01e5a645a8a4c33a83f580f9fb04151954471c7c Mon Sep 17 00:00:00 2001 From: Shineast Date: Tue, 30 Apr 2024 11:34:55 +0900 Subject: [PATCH 07/19] =?UTF-8?q?[BOJ]=20=ED=94=BC=EB=B3=B4=EB=82=98?= =?UTF-8?q?=EC=B9=98=20=EC=88=98=205=20/=20=EB=B8=8C=EB=A1=A0=EC=A6=88=202?= =?UTF-8?q?=20/=2019=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/10870 --- kangdy25/BOJ/10870.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 kangdy25/BOJ/10870.cpp diff --git a/kangdy25/BOJ/10870.cpp b/kangdy25/BOJ/10870.cpp new file mode 100644 index 000000000..45e6cdc52 --- /dev/null +++ b/kangdy25/BOJ/10870.cpp @@ -0,0 +1,24 @@ +// 피보나치 수 5 / 브론즈 2 + +#include +using namespace std; + +int Fibonacci(int n) { + if (n == 0) { + return 0; + } else if (n == 1) { + return 1; + } else { + return Fibonacci(n - 2) + Fibonacci(n - 1); + } +} + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N; + cin >> N; + + cout << Fibonacci(N) << "\n"; +} \ No newline at end of file From 435f30ee9bc812cbd0d547f454bc1fbfd8af2d5f Mon Sep 17 00:00:00 2001 From: Shineast Date: Tue, 30 Apr 2024 11:36:12 +0900 Subject: [PATCH 08/19] =?UTF-8?q?[BOJ]=20=EC=9E=AC=EA=B7=80=EC=9D=98=20?= =?UTF-8?q?=EA=B7=80=EC=9E=AC=20/=20=EB=B8=8C=EB=A1=A0=EC=A6=882=20/=2032?= =?UTF-8?q?=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/25501 --- kangdy25/BOJ/25501.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 kangdy25/BOJ/25501.cpp diff --git a/kangdy25/BOJ/25501.cpp b/kangdy25/BOJ/25501.cpp new file mode 100644 index 000000000..4b61db596 --- /dev/null +++ b/kangdy25/BOJ/25501.cpp @@ -0,0 +1,38 @@ +// 재귀의 귀재 / 브론즈 2 +#include +using namespace std; + +int cnt = 0; + +int recursion(const char* s, int l, int r) { + cnt++; + if (l >= r) { + return 1; + } + else if (s[l] != s[r]) { + return 0; + } + else { + return recursion(s, l + 1, r - 1); + } +} + +int isPalindrome(const char* s) { + return recursion(s, 0, strlen(s) - 1); +} + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int T; + string S; + cin >> T; + + for (int i = 0; i < T; i++) { + cnt = 0; + cin >> S; + cout << isPalindrome(S.c_str()) << " " << cnt << "\n"; + } + +} \ No newline at end of file From 62cdfa1ed058b29a4db4535473c6a77ab41d31a9 Mon Sep 17 00:00:00 2001 From: Shineast Date: Sat, 25 May 2024 12:06:57 +0900 Subject: [PATCH 09/19] =?UTF-8?q?[BOJ]=20=EC=8A=A4=ED=83=9D=202=20/=20?= =?UTF-8?q?=EC=8B=A4=EB=B2=84=204=20/=203=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kangdy25/BOJ/28278.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 kangdy25/BOJ/28278.cpp diff --git a/kangdy25/BOJ/28278.cpp b/kangdy25/BOJ/28278.cpp new file mode 100644 index 000000000..9eeeec53d --- /dev/null +++ b/kangdy25/BOJ/28278.cpp @@ -0,0 +1,50 @@ +// 스택 2 / 실버 4 + +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N, cmd, x; + cin >> N; + stack s; + + while(N--) { + cin >> cmd; + switch (cmd) { + case 1: + cin >> x; + s.push(x); + break; + case 2: + if (s.empty()) { + cout << "-1\n"; + } else { + cout << s.top() << "\n"; + s.pop(); + } + break; + case 3: + cout << s.size() << "\n"; + break; + case 4: + if (s.empty()) { + cout << "1\n"; + } else { + cout << "0\n"; + } + break; + case 5: + if (s.empty()) { + cout << "-1\n"; + } else { + cout << s.top() << "\n"; + } + break; + default: // do nothing + break; + } + } +} \ No newline at end of file From c48d6406157fdbf5dd98aa5933ebf0eaddb5b386 Mon Sep 17 00:00:00 2001 From: Shineast Date: Sat, 25 May 2024 12:08:10 +0900 Subject: [PATCH 10/19] =?UTF-8?q?[BOJ]=20=EC=A0=9C=EB=A1=9C=20/=20?= =?UTF-8?q?=EC=8B=A4=EB=B2=84=204=20/=204=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/10773 --- kangdy25/BOJ/10773.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 kangdy25/BOJ/10773.cpp diff --git a/kangdy25/BOJ/10773.cpp b/kangdy25/BOJ/10773.cpp new file mode 100644 index 000000000..28662b576 --- /dev/null +++ b/kangdy25/BOJ/10773.cpp @@ -0,0 +1,29 @@ +// 제로 / 실버 4 + +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int K, num, total = 0; + cin >> K; + stack money; + + while (K--) { + cin >> num; + if (num == 0) { + money.pop(); + } + else { + money.push(num); + } + } + + while (!money.empty()) { + total += money.top(); + money.pop(); + } + cout << total << "\n"; +} \ No newline at end of file From a296853bc93e6f08baec6eb705f3bdbf227a0191 Mon Sep 17 00:00:00 2001 From: Shineast Date: Sat, 25 May 2024 12:09:25 +0900 Subject: [PATCH 11/19] =?UTF-8?q?[BOJ]=20=EA=B4=84=ED=98=B8=20/=20?= =?UTF-8?q?=EC=8B=A4=EB=B2=84=204=20/=2010=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/9012 --- kangdy25/BOJ/9012.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 kangdy25/BOJ/9012.cpp diff --git a/kangdy25/BOJ/9012.cpp b/kangdy25/BOJ/9012.cpp new file mode 100644 index 000000000..94567f460 --- /dev/null +++ b/kangdy25/BOJ/9012.cpp @@ -0,0 +1,43 @@ +// 괄호 / 실버 4 + +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N; + cin >> N; + string s; + + while (N--) { + bool check = true; + cin >> s; + stack st; + for (int i = 0; i < s.size(); i++) { + if (s[i] == '(') { + st.push(s[i]); + } + else { + if (!st.empty() && st.top() == '(') { + st.pop(); + } + else { + cout << "NO\n"; + check = false; + break; + } + } + } + if (check) { + if (st.empty()) { + cout << "YES\n"; + } + else { + cout << "NO\n"; + } + + } + } +} \ No newline at end of file From be1ee14f76cd1a7b7076b9de0ac5c70f6492dcb7 Mon Sep 17 00:00:00 2001 From: Shineast Date: Sat, 25 May 2024 12:10:21 +0900 Subject: [PATCH 12/19] =?UTF-8?q?[BOJ]=20=EA=B7=A0=ED=98=95=EC=9E=A1?= =?UTF-8?q?=ED=9E=8C=20=EC=84=B8=EC=83=81=20/=20=EC=8B=A4=EB=B2=84=204=20/?= =?UTF-8?q?=2023=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/4949 --- kangdy25/BOJ/4949.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 kangdy25/BOJ/4949.cpp diff --git a/kangdy25/BOJ/4949.cpp b/kangdy25/BOJ/4949.cpp new file mode 100644 index 000000000..289992ebd --- /dev/null +++ b/kangdy25/BOJ/4949.cpp @@ -0,0 +1,55 @@ +// 균형잡힌 세상 / 실버 4 + +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + string s = ""; + + while (true) { + bool check = true; + getline(cin, s); + stack st; + + if (s[0] == '.') { + break; + } + + for (int i = 0; i < s.size(); i++) { + if (s[i] == '[' || s[i] == '(') { + st.push(s[i]); + } + else if (s[i] == ']') { + if (!st.empty() && st.top() == '[') { + st.pop(); + } + else { + cout << "no\n"; + check = false; + break; + } + } + else if (s[i] == ')') { + if (!st.empty() && st.top() == '(') { + st.pop(); + } + else { + cout << "no\n"; + check = false; + break; + } + } + } + if (check) { + if (st.empty()) { + cout << "yes\n"; + } + else { + cout << "no\n"; + } + } + } +} \ No newline at end of file From dd4735b2ef2d973cacf803fa62d759c5cc090252 Mon Sep 17 00:00:00 2001 From: Shineast Date: Sat, 25 May 2024 12:11:27 +0900 Subject: [PATCH 13/19] =?UTF-8?q?[BOJ]=20=EB=8F=84=ED=82=A4=EB=8F=84?= =?UTF-8?q?=ED=82=A4=20=EA=B0=84=EC=8B=9D=EB=93=9C=EB=A6=AC=EB=AF=B8=20/?= =?UTF-8?q?=20=EC=8B=A4=EB=B2=84=203=20/=2025=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/12789 --- kangdy25/BOJ/12789.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 kangdy25/BOJ/12789.cpp diff --git a/kangdy25/BOJ/12789.cpp b/kangdy25/BOJ/12789.cpp new file mode 100644 index 000000000..84bd25da7 --- /dev/null +++ b/kangdy25/BOJ/12789.cpp @@ -0,0 +1,32 @@ +// 도키도키 간식드리미 / 실버 3 + +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N, num, cnt = 1; + cin >> N; + stack st; + + for (int i = 0; i < N; i++) { + cin >> num; + if (num == cnt) { + cnt++; + } else { + st.push(num); + } + + while(!st.empty() && st.top() == cnt) { + st.pop(); + cnt++; + } + } + if (st.empty()) { + cout << "Nice\n"; + } else { + cout << "Sad\n"; + } +} \ No newline at end of file From bce55682808d88e2f6550c1759b2bfcef33abae9 Mon Sep 17 00:00:00 2001 From: Shineast Date: Sat, 25 May 2024 12:12:17 +0900 Subject: [PATCH 14/19] =?UTF-8?q?[BOJ]=20=ED=81=90=202=20/=20=EC=8B=A4?= =?UTF-8?q?=EB=B2=84=204=20/=204=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/18258 --- kangdy25/BOJ/18258.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 kangdy25/BOJ/18258.cpp diff --git a/kangdy25/BOJ/18258.cpp b/kangdy25/BOJ/18258.cpp new file mode 100644 index 000000000..2eec5cc6a --- /dev/null +++ b/kangdy25/BOJ/18258.cpp @@ -0,0 +1,49 @@ +// 큐 2 / 실버 4 + +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N, num; + string s; + queue q; + cin >> N; + + while(N--) { + cin >> s; + if (s == "push") { + cin >> num; + q.push(num); + } else if (s == "pop") { + if (!q.empty()) { + cout << q.front() << "\n"; + q.pop(); + } else { + cout << "-1\n"; + } + } else if (s == "size") { + cout << q.size() << "\n"; + } else if (s == "empty") { + if (q.empty()) { + cout << "1\n"; + } else { + cout << "0\n"; + } + } else if (s == "front") { + if (q.empty()) { + cout << "-1\n"; + } else { + cout << q.front() << "\n"; + } + } else if (s == "back") { + if (q.empty()) { + cout << "-1\n"; + } else { + cout << q.back() << "\n"; + } + } + } +} \ No newline at end of file From b1de5210d8810c5fe89f8f857dde308b6691a091 Mon Sep 17 00:00:00 2001 From: Shineast Date: Sat, 25 May 2024 12:13:15 +0900 Subject: [PATCH 15/19] =?UTF-8?q?[BOJ]=20=EC=B9=B4=EB=93=9C=202=20/=20?= =?UTF-8?q?=EC=8B=A4=EB=B2=84=204=20/=2018=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/2164 --- kangdy25/BOJ/2164.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 kangdy25/BOJ/2164.cpp diff --git a/kangdy25/BOJ/2164.cpp b/kangdy25/BOJ/2164.cpp new file mode 100644 index 000000000..bdf0811c9 --- /dev/null +++ b/kangdy25/BOJ/2164.cpp @@ -0,0 +1,34 @@ +// 카드2 / 실버 4 + +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N; + cin >> N; + queue q; + bool check = true; + + for (int i = 1; i <= N; i++) { + q.push(i); + } + if (N == 1) { + cout << "1\n"; + } else { + while(q.size() != 1) { + if (check) { + q.pop(); + check = false; + } else { + q.push(q.front()); + q.pop(); + check = true; + } + N--; + } + cout << q.back() << "\n"; + } +} \ No newline at end of file From 15a13adb52950e7d70857cded59a38e9c06f35b4 Mon Sep 17 00:00:00 2001 From: Shineast Date: Sat, 25 May 2024 12:14:27 +0900 Subject: [PATCH 16/19] =?UTF-8?q?[BOJ]=20=EC=9A=94=EC=84=B8=ED=91=B8?= =?UTF-8?q?=EC=8A=A4=20=EB=AC=B8=EC=A0=9C=200=20/=20=EC=8B=A4=EB=B2=84=205?= =?UTF-8?q?=20/=2016=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/11866 --- kangdy25/BOJ/11866.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 kangdy25/BOJ/11866.cpp diff --git a/kangdy25/BOJ/11866.cpp b/kangdy25/BOJ/11866.cpp new file mode 100644 index 000000000..6dda15e88 --- /dev/null +++ b/kangdy25/BOJ/11866.cpp @@ -0,0 +1,31 @@ +// 요세푸스 문제 0 / 실버 5 + +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N, K; + cin >> N >> K; + queue q; + + for (int i = 1; i <= N; i++) { + q.push(i); + } + + cout << "<"; + while (!q.empty()) { + for (int i = 1; i < K; i++) { + q.push(q.front()); + q.pop(); + } + cout << q.front(); + if (q.size() > 1) { + cout << ", "; + } + q.pop(); + } + cout << ">"; +} \ No newline at end of file From 2db8b9d335f80b4b2482d57551349f9ae3c29a73 Mon Sep 17 00:00:00 2001 From: Shineast Date: Sat, 25 May 2024 12:15:14 +0900 Subject: [PATCH 17/19] =?UTF-8?q?[BOJ]=20=EB=8D=B1=202=20/=20=EC=8B=A4?= =?UTF-8?q?=EB=B2=84=204=20/=208=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/28279 --- kangdy25/BOJ/28279.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 kangdy25/BOJ/28279.cpp diff --git a/kangdy25/BOJ/28279.cpp b/kangdy25/BOJ/28279.cpp new file mode 100644 index 000000000..e69de29bb From 4c8d34f9df1aee0a309f5103500e55db2d9968c7 Mon Sep 17 00:00:00 2001 From: Shineast Date: Sat, 25 May 2024 12:16:20 +0900 Subject: [PATCH 18/19] =?UTF-8?q?[BOJ]=20=ED=92=8D=EC=84=A0=20=ED=84=B0?= =?UTF-8?q?=EB=9C=A8=EB=A6=AC=EA=B8=B0=20/=20=EC=8B=A4=EB=B2=84=203=20/=20?= =?UTF-8?q?31=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/2346 --- kangdy25/BOJ/2346.cpp | 39 ++++++++++++++++++++++++ kangdy25/BOJ/28279.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 kangdy25/BOJ/2346.cpp diff --git a/kangdy25/BOJ/2346.cpp b/kangdy25/BOJ/2346.cpp new file mode 100644 index 000000000..7f235e617 --- /dev/null +++ b/kangdy25/BOJ/2346.cpp @@ -0,0 +1,39 @@ +// 풍선 터뜨리기 / 실버 3 + +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N, pop, coord, popTargetValue, popTargetCoord; + cin >> N; + deque> dq; + + for (int i = 1; i <= N; i++) { + cin >> coord; + dq.push_back(make_pair(coord, i)); + } + + while (!dq.empty()) { + popTargetCoord = dq.front().first; + popTargetValue = dq.front().second; + + cout << popTargetValue << " "; + dq.pop_front(); + + if (!dq.empty() && popTargetCoord > 0) { + for (int i = 1; i < popTargetCoord; i++) { + dq.push_back(dq.front()); + dq.pop_front(); + } + } + else if (!dq.empty() && popTargetCoord < 0) { + for (int i = 1; i < popTargetCoord * (-1) + 1; i++) { + dq.push_front(dq.back()); + dq.pop_back(); + } + } + } +} \ No newline at end of file diff --git a/kangdy25/BOJ/28279.cpp b/kangdy25/BOJ/28279.cpp index e69de29bb..3ec790e13 100644 --- a/kangdy25/BOJ/28279.cpp +++ b/kangdy25/BOJ/28279.cpp @@ -0,0 +1,69 @@ +// 덱 2 / 실버 4 + +#include +using namespace std; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int N, cmd, num; + cin >> N; + deque dq; + + while(N--) { + cin >> cmd; + switch (cmd) { + case 1: + cin >> num; + dq.push_front(num); + break; + case 2: + cin >> num; + dq.push_back(num); + break; + case 3: + if (!dq.empty()) { + cout << dq.front() << "\n"; + dq.pop_front(); + } else { + cout << "-1\n"; + } + break; + case 4: + if (!dq.empty()) { + cout << dq.back() << "\n"; + dq.pop_back(); + } else { + cout << "-1\n"; + } + break; + case 5: + cout << dq.size() << "\n"; + break; + case 6: + if (!dq.empty()) { + cout << "0\n"; + } else { + cout << "1\n"; + } + break; + case 7: + if (!dq.empty()) { + cout << dq.front() << "\n"; + } else { + cout << "-1\n"; + } + break; + case 8: + if (!dq.empty()) { + cout << dq.back() << "\n"; + } else { + cout << "-1\n"; + } + break; + default: + break; + } + } +} \ No newline at end of file From 78b6f789244f94dd022912bf5aa0ae065d8e7a7c Mon Sep 17 00:00:00 2001 From: Shineast Date: Sat, 25 May 2024 12:17:21 +0900 Subject: [PATCH 19/19] =?UTF-8?q?[BOJ]=20queuestack=20/=20=EC=8B=A4?= =?UTF-8?q?=EB=B2=84=203=20/=2021=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/24511 --- kangdy25/BOJ/24511.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 kangdy25/BOJ/24511.cpp diff --git a/kangdy25/BOJ/24511.cpp b/kangdy25/BOJ/24511.cpp new file mode 100644 index 000000000..cf71a16fd --- /dev/null +++ b/kangdy25/BOJ/24511.cpp @@ -0,0 +1,35 @@ +// queuestack / 실버 3 + +#include +using namespace std; + +int N, M, check, queuestack[100001]; +deque dq; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + cin >> N; + for (int i = 0; i < N; i++) { + cin >> check; + queuestack[i] = check; + } + for (int i = 0; i < N; i++) { + int x; + cin >> x; + if (queuestack[i] == 0) { + dq.push_back(x); + } + } + + cin >> M; + for (int i = 0; i < M; i++) { + int x; + cin >> x; + dq.push_front(x); + cout << dq.back() << " "; + dq.pop_back(); + } + +} \ No newline at end of file