본문 바로가기

Problem Solving1245

[백준] 22035 Bus Lines - Graph Theory / Java • 문제 링크 22035번: Bus Lines If it is not possible to construct a graph with the given properties, print "-1". Otherwise, print $m$ lines where the $i$'th line contains two integers $a_i$, $b_i$, the endpoints of the $i$'th edge. If there are many possible solutions, any one of them w www.acmicpc.net • 풀이 코드 import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWrite.. 2024. 3. 9.
[백준] 5247 Mining Maps - Graph Theory / Java • 문제 링크 5247번: Mining Maps Connections between mines are described beginning with the line ”GRAPH BEGIN”. Additional lines lists individual mines (nodes), followed (on the same line) by their neighboring mines (edges). The line ”GRAPH END” ends the list of path descriptions. www.acmicpc.net • 풀이 코드 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import j.. 2024. 3. 8.
[백준] 20914 QWERTY 자판 - Graph Theory / Java • 문제 링크 20914번: QWERTY 자판 Albert는 QWERTY 키보드를 이용해 (위 그림 참고) 영문 대문자로 ('A'-'Z') 구성된 문자열을 입력하고 싶다. 아직 키보드 만지는 것이 서툰 Albert는 왼쪽 검지만을 이용해 버튼을 누르는 버릇이 있다. www.acmicpc.net • 풀이 코드 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayDeque; import java.util.Queue; public class .. 2024. 3. 7.
[백준] 6179 Oh Those Rollers - Graph Theory / Java • 문제 링크 6179번: Oh Those Rollers Farmer John has installed a new winch that gives him mechanical advantage when lifting bales of hay into the barn. The winch was manufactured by the Rube Goldberg Winch Company and has way too many rollers to make any sense at all. The winch has a huge ste www.acmicpc.net • 풀이 코드 import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStrea.. 2024. 3. 6.
[백준] 10451 순열 사이클 - Graph Theory / Java • 문제 링크 10451번: 순열 사이클 1부터 N까지 정수 N개로 이루어진 순열을 나타내는 방법은 여러 가지가 있다. 예를 들어, 8개의 수로 이루어진 순열 (3, 2, 7, 8, 1, 4, 5, 6)을 배열을 이용해 표현하면 \(\begin{pmatrix} 1 & 2 &3&4&5&6&7&8 \\ 3 www.acmicpc.net • 풀이 코드 import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { static int[] arr; static boolean[] visit; public static void main(String[] args) throws IO.. 2024. 3. 5.
[백준] 9897 Lamp - Data Structure / Java • 문제 링크 9897번: Lamp A building has a long corridor and L ceiling lamps labeled 1, 2, 3, ..., L. Each lamp has an individual switch that can turn the lamp on or off. The building manager hires G security guards (no two guards have the same name), whose job at night is to www.acmicpc.net • 풀이 코드 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.i.. 2024. 3. 4.