<C/C++> BOJ 13458 ์‹œํ—˜๊ฐ๋…
Coding Test 2022. 3. 30. 21:41

https://www.acmicpc.net/problem/13458 13458๋ฒˆ: ์‹œํ—˜ ๊ฐ๋… ์ฒซ์งธ ์ค„์— ์‹œํ—˜์žฅ์˜ ๊ฐœ์ˆ˜ N(1 ≤ N ≤ 1,000,000)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ ์ค„์—๋Š” ๊ฐ ์‹œํ—˜์žฅ์— ์žˆ๋Š” ์‘์‹œ์ž์˜ ์ˆ˜ Ai (1 ≤ Ai ≤ 1,000,000)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์…‹์งธ ์ค„์—๋Š” B์™€ C๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (1 ≤ B, C ≤ 1,000,000) www.acmicpc.net #include #include using namespace std; #define MAXN 1000000 int N, B, C; int test[MAXN + 10]; void Input(void) { cin >> N; for (int i = 0; i > test[i]; } cin >> B >> C; } voi..

<C/C++> BOJ 14499: ์ฃผ์‚ฌ์œ„ ๊ตด๋ฆฌ๊ธฐ
Coding Test 2022. 3. 30. 21:38

https://www.acmicpc.net/problem/14499 14499๋ฒˆ: ์ฃผ์‚ฌ์œ„ ๊ตด๋ฆฌ๊ธฐ ์ฒซ์งธ ์ค„์— ์ง€๋„์˜ ์„ธ๋กœ ํฌ๊ธฐ N, ๊ฐ€๋กœ ํฌ๊ธฐ M (1 ≤ N, M ≤ 20), ์ฃผ์‚ฌ์œ„๋ฅผ ๋†“์€ ๊ณณ์˜ ์ขŒํ‘œ x, y(0 ≤ x ≤ N-1, 0 ≤ y ≤ M-1), ๊ทธ๋ฆฌ๊ณ  ๋ช…๋ น์˜ ๊ฐœ์ˆ˜ K (1 ≤ K ≤ 1,000)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ N๊ฐœ์˜ ์ค„์— ์ง€ www.acmicpc.net #include #include #include using namespace std; #define MAXN 20 #define MAXN2 1000 int dice[4][3] = { 0, };// ์ฃผ์‚ฌ์œ„๋ฉด์— ์ ํ˜€์žˆ๋Š” ์ˆซ์ž static int dr[] = { 0, 0, 0, -1, 1 }; static int dc[] = { 0, 1..

<C/C++> BOJ 13460: ๊ตฌ์Šฌํƒˆ์ถœ
Coding Test 2022. 3. 29. 14:33

์˜ค๋Š˜๋ถ€ํ„ฐ ํ•˜๋ฃจ์— ํ•œ๋‘๋ฌธ์ œ์”ฉ ๊ฐœ๋ณ„์ ์œผ๋กœ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋ฅผ ํ’€์–ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค! #include #include using namespace std; #define MAXN 10 int N, M; int RR, RC, BR, BC; int rcnt, bcnt; char map[MAXN + 5][MAXN + 5]; int visited[MAXN + 5][MAXN + 5][MAXN + 5][MAXN + 5]; struct DATA { int rr, rc, br, bc, t; }; queue q; static int dr[] = { -1, 1, 0, 0 }; static int dc[] = { 0, 0, -1, 1 }; void tilt(int &r, int &c, int &cnt, int i) { for (;;) ..

LeetCode - Longest Common Prefix
Coding Test 2021. 11. 11. 19:21

1. Description Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: strs = ["flower","flow","flight"] Output: "fl" Example 2: Input: strs = ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input strings. Constraints: 1

LeetCode - Roman to Integer
Coding Test 2021. 11. 10. 09:50

Description Roman numerals are represented by seven different symbols: I, V, X, L, C, Dand M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two one's added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II. Roman numerals are usually written largest to smallest from left to ri..

LeetCode - Palindrome
Coding Test 2021. 11. 10. 02:05

Description Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not. Example 1: Input: x = 121 Output: true Example 2: Input: x = -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. Example..