๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

2๏ธโƒฃ Java38

[Java Algorithm] ์ˆจ๋ฐ”๊ผญ์งˆ 2 BOJ #12851 ๋ฌธ์ œ https://www.acmicpc.net/problem/12851 12851๋ฒˆ: ์ˆจ๋ฐ”๊ผญ์งˆ 2 ์ˆ˜๋นˆ์ด๋Š” ๋™์ƒ๊ณผ ์ˆจ๋ฐ”๊ผญ์งˆ์„ ํ•˜๊ณ  ์žˆ๋‹ค. ์ˆ˜๋นˆ์ด๋Š” ํ˜„์žฌ ์  N(0 ≤ N ≤ 100,000)์— ์žˆ๊ณ , ๋™์ƒ์€ ์  K(0 ≤ K ≤ 100,000)์— ์žˆ๋‹ค. ์ˆ˜๋นˆ์ด๋Š” ๊ฑท๊ฑฐ๋‚˜ ์ˆœ๊ฐ„์ด๋™์„ ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋งŒ์•ฝ, ์ˆ˜๋นˆ์ด์˜ ์œ„์น˜๊ฐ€ X์ผ ๋•Œ www.acmicpc.net ๋‚ด ๋ฌธ์ œ ํ’€์ด import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.Deque; import java.util.StringTokenizer; public class BOJ_12851 { static Deque q.. 2022. 8. 16.
[Java Algorithm] ์‚ฌ์น™์—ฐ์‚ฐ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ SWEA #1233 ๋ฌธ์ œ https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV141176AIwCFAYD SW Expert Academy SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”! swexpertacademy.com ๋‚ด ๋ฌธ์ œ ํ’€์ด import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Solution { public static void main(String[] args) throws Exception { BufferedReader in = new Buffered.. 2022. 8. 11.
[Java Algorithm] ๋ฐฐ์—ด ๋Œ๋ฆฌ๊ธฐ 4 BOJ #17406 ๋ฌธ์ œ https://www.acmicpc.net/problem/17406 17406๋ฒˆ: ๋ฐฐ์—ด ๋Œ๋ฆฌ๊ธฐ 4 ํฌ๊ธฐ๊ฐ€ N×M ํฌ๊ธฐ์ธ ๋ฐฐ์—ด A๊ฐ€ ์žˆ์„๋•Œ, ๋ฐฐ์—ด A์˜ ๊ฐ’์€ ๊ฐ ํ–‰์— ์žˆ๋Š” ๋ชจ๋“  ์ˆ˜์˜ ํ•ฉ ์ค‘ ์ตœ์†Ÿ๊ฐ’์„ ์˜๋ฏธํ•œ๋‹ค. ๋ฐฐ์—ด A๊ฐ€ ์•„๋ž˜์™€ ๊ฐ™์€ ๊ฒฝ์šฐ 1ํ–‰์˜ ํ•ฉ์€ 6, 2ํ–‰์˜ ํ•ฉ์€ 4, 3ํ–‰์˜ ํ•ฉ์€ 15์ด๋‹ค. ๋”ฐ๋ผ์„œ, ๋ฐฐ์—ด A์˜ www.acmicpc.net ๋‚ด ๋ฌธ์ œ ํ’€์ด import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int n, m, k; static int[][] nums; static int[][] cals; static int min.. 2022. 8. 10.
[Java Algorithm] ๋ฐฐ์—ด ๋Œ๋ฆฌ๊ธฐ 2 BOJ #16927 ๋ฌธ์ œ https://www.acmicpc.net/problem/16927 16927๋ฒˆ: ๋ฐฐ์—ด ๋Œ๋ฆฌ๊ธฐ 2 ํฌ๊ธฐ๊ฐ€ N×M์ธ ๋ฐฐ์—ด์ด ์žˆ์„ ๋•Œ, ๋ฐฐ์—ด์„ ๋Œ๋ ค๋ณด๋ ค๊ณ  ํ•œ๋‹ค. ๋ฐฐ์—ด์€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ฐ˜์‹œ๊ณ„ ๋ฐฉํ–ฅ์œผ๋กœ ๋Œ๋ ค์•ผ ํ•œ๋‹ค. A[1][1] ← A[1][2] ← A[1][3] ← A[1][4] ← A[1][5] ↓ ↑ A[2][1] A[2][2] ← A[2][3] ← A[2][4] A[2][5] www.acmicpc.net ๋‚ด ๋ฌธ์ œ ํ’€์ด import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int[][] nums; static int n, m, r;.. 2022. 8. 10.
[Java Algorithm] ํ…€ ํ”„๋กœ์ ํŠธ BOJ #9466 ๋ฌธ์ œ https://www.acmicpc.net/problem/9466 9466๋ฒˆ: ํ…€ ํ”„๋กœ์ ํŠธ ์ด๋ฒˆ ๊ฐ€์„ํ•™๊ธฐ์— '๋ฌธ์ œ ํ•ด๊ฒฐ' ๊ฐ•์˜๋ฅผ ์‹ ์ฒญํ•œ ํ•™์ƒ๋“ค์€ ํ…€ ํ”„๋กœ์ ํŠธ๋ฅผ ์ˆ˜ํ–‰ํ•ด์•ผ ํ•œ๋‹ค. ํ”„๋กœ์ ํŠธ ํŒ€์› ์ˆ˜์—๋Š” ์ œํ•œ์ด ์—†๋‹ค. ์‹ฌ์ง€์–ด ๋ชจ๋“  ํ•™์ƒ๋“ค์ด ๋™์ผํ•œ ํŒ€์˜ ํŒ€์›์ธ ๊ฒฝ์šฐ์™€ ๊ฐ™์ด ํ•œ ํŒ€๋งŒ ์žˆ์„ www.acmicpc.net ๋‚ด ๋ฌธ์ œ ํ’€์ด import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int[] stu; static boolean[] cycle, visited; static int cnt; // ์‹ธ์ดํด์— ํฌํ•จ๋œ ํ•™์ƒ ์ˆ˜ public stati.. 2022. 8. 9.