PS/boj
-
boj)2667 - 단지번호붙이기PS/boj 2020. 9. 3. 16:02
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static int n, danjiCnt; static int[][] graph = new int[26][26]; static int[] num = new int[26*26]; static boolean dfs (int x, int y) { if (x n || y n) { return false; } // 단지가 될 수 있다면 if (graph[x][y] == 1) { graph[x][y] = 0; num[danjiCnt]++; d..
-
boj)2606 - 바이러스PS/boj 2020. 9. 3. 13:05
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static int n, m, node1, node2, cnt; static LinkedList[] nodeList; static boolean[] visited = new boolean[101]; public static void dfs(int node) { if (visited[node]) return; visited[node] = true; cnt++; for (int nextNode : nodeList[node]) { dfs(nextNode); } } public..
-
boj)1260 - DFS와 BFSPS/boj 2020. 9. 3. 12:25
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static int n, m, v; static LinkedList[] nodeList; static boolean[] checked = new boolean[1001]; static boolean[] checked2 = new boolean[1001]; public static void dfs(int node) { if (checked[node]) return; checked[node] = true; System.out.print(node + " "); for (int..
-
boj)18352 - 특정 거리의 도시 찾기PS/boj 2020. 9. 2. 17:39
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static int n, m, k, x; public static ArrayList graph = new ArrayList(); // 모든 도시에 대한 최단 거리 초기화 public static int[] d = new int[300001]; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(S..
-
boj)1459 - 걷기PS/boj 2020. 8. 31. 19:34
import java.io.*; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); long X = Long.parseLong(st.nextToken()); // ~10억 long Y = Long.parseLong(st.nextToken()); // ~10억 long W = Long.parseLong(st.nextToken(..
-
boj)12018 - Yonsei TOTOPS/boj 2020. 8. 31. 18:06
import java.io.*; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int ans = 0; StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); // 과목 수 int m = Integer.p..
-
boj)2012 - 등수 매기기PS/boj 2020. 8. 31. 17:14
import java.io.*; import java.util.Arrays; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int[] arr = new int[N]; long ans = 0; for (int i = 0; i < arr.length; i++) { arr[i] = Integer.parseInt(br.readLine()); } Arrays.sort(arr); for (int i = 0; i < a..
-
boj)1911 - 흙길 보수하기PS/boj 2020. 8. 31. 16:42
import java.io.*; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int N = Integer.parseInt(st.nextToken()); // 웅덩이 갯수 int L = Integer.parseInt(st.n..