From c826b20a58845b514313e2731754782d625ca7c4 Mon Sep 17 00:00:00 2001 From: hannahf97 <46432606+hannahf97@users.noreply.github.com> Date: Wed, 25 May 2022 12:19:25 +0900 Subject: [PATCH 1/6] =?UTF-8?q?kjh=203=EC=A3=BC=EC=B0=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../220524/Main.java" | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 "source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220524/Main.java" diff --git "a/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220524/Main.java" "b/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220524/Main.java" new file mode 100644 index 0000000..e26cc9b --- /dev/null +++ "b/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220524/Main.java" @@ -0,0 +1,77 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.util.StringTokenizer; + +public class Main{ + static int R,C; + static char[][] maps; + static boolean[][] visited; + static int dx[] = {1,0,-1,0}; + static int dy[] = {0,1,0,-1}; + static Queue queue = new LinkedList<>(); + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + R = Integer.parseInt(st.nextToken()); + C = Integer.parseInt(st.nextToken()); + visited =new boolean[R][C]; + maps = new char[R][C]; + + int vcount = 0; + int ocount =0; + for(int i=0; i=0 && nX < R && nY >=0 && nY < C){ + if(maps[nX][nY] == 'V' && !visited[nX][nY]){ + queue.add(new int[]{nX,nY}); + vistied[nX][nY] = true; + vcount +=1; + } + else if(maps[nX][nY] == '#'){ + continue; + } + else if(maps[nX][nY] == '.' && !visited[nX][nY]){ + queue.add(new int[]{nX,nY}); + visited[nX][nY] = true; + } + else if(maps[nX][nY] == 'O'){ + ocount += 1; + } + } + + } + } + } +} \ No newline at end of file From c1f24d594b92c05da6e00c7c65fd27449874bf36 Mon Sep 17 00:00:00 2001 From: hannahf97 <46432606+hannahf97@users.noreply.github.com> Date: Wed, 25 May 2022 12:20:54 +0900 Subject: [PATCH 2/6] =?UTF-8?q?kjh=203=EC=A3=BC=EC=B0=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../220524/bj3184.md" | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) rename "source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220524/Main.java" => "source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220524/bj3184.md" (97%) diff --git "a/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220524/Main.java" "b/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220524/bj3184.md" similarity index 97% rename from "source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220524/Main.java" rename to "source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220524/bj3184.md" index e26cc9b..a19b6fa 100644 --- "a/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220524/Main.java" +++ "b/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220524/bj3184.md" @@ -1,3 +1,8 @@ +## 양 + +dfs/bfs 다시 시작하겠습니다.. + +```java import java.io.BufferedReader; import java.io.IOException; import java.util.StringTokenizer; @@ -74,4 +79,5 @@ else if(maps[nX][nY] == 'O'){ } } } -} \ No newline at end of file +} +``` From bcba48554ba892a789cbb06d99a1e54713e75dd9 Mon Sep 17 00:00:00 2001 From: hannahf97 <46432606+hannahf97@users.noreply.github.com> Date: Wed, 25 May 2022 19:57:29 +0900 Subject: [PATCH 3/6] 0525 kjh --- .../220525/bj2606.md" | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 "source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220525/bj2606.md" diff --git "a/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220525/bj2606.md" "b/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220525/bj2606.md" new file mode 100644 index 0000000..6d1bb6b --- /dev/null +++ "b/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220525/bj2606.md" @@ -0,0 +1,57 @@ +## 바이러스 + +예전에 풀었던 문제라 쉬웠따 +bfs지만, queue를 사용하지 않고 재귀를 통해 풀었다. + +```java + +import java.io.BufferedReader; +import java.io.IOException; +import java.util.StringTokenizer; +import java.util.*; +import java.io.*; + +public class Main{ + + static int n,m; + static ArrayList[] arrayList; + static boolean[] visited; + static int count=0; + public static void main(String[] args)throws IOException{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + n = Integer.parseInt(br.readLine()); //컴퓨터 수 + m = Integer.parseInt(br.readLine()); //컴퓨터 번호 쌍 + arrayList = new ArrayList[n+1]; + visited = new boolean[n+1]; + + for(int i=1; i<=n; i++){ + arrayList[i] = new ArrayList(); + } + + for(int i=0; i Date: Fri, 27 May 2022 19:16:53 +0900 Subject: [PATCH 4/6] 220527 kjh --- .../220527/bj11403.md" | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 "source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220527/bj11403.md" diff --git "a/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220527/bj11403.md" "b/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220527/bj11403.md" new file mode 100644 index 0000000..ae1ffba --- /dev/null +++ "b/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220527/bj11403.md" @@ -0,0 +1,52 @@ +## 경로 찾기 + +```javascript +import java.io.BufferedReader; +import java.io.IOException; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.ArrayList; +import java.util.StringTokenizer; + +public class Main{ + public static void main(String[] args) throws IOException{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + int n = Integer.parseInt(br.readLine()); + int[][] arr = new int[n][n]; + + for(int i=0; i Date: Sun, 29 May 2022 00:11:00 +0900 Subject: [PATCH 5/6] 0529 kjh --- .../220529/bj11725.md" | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 "source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220529/bj11725.md" diff --git "a/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220529/bj11725.md" "b/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220529/bj11725.md" new file mode 100644 index 0000000..dd2b811 --- /dev/null +++ "b/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220529/bj11725.md" @@ -0,0 +1,49 @@ +## 트리의 부모찾기 + +parents 생각하는 부분이 어려웠다. + +```java +import java.util.*; +import java.io.*; +public class Main +{ + static boolean visited[]; + static int N; + static ArrayList[] arr; + public static void main(String[] args) throws IOException{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + arr = new ArrayList[N+1]; + visited = new boolean[N+1]; + for(int i=1; i Date: Tue, 7 Jun 2022 00:00:06 +0900 Subject: [PATCH 6/6] kjh 0606 --- .../220606/bj7562.md" | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 "source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220606/bj7562.md" diff --git "a/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220606/bj7562.md" "b/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220606/bj7562.md" new file mode 100644 index 0000000..8b2e295 --- /dev/null +++ "b/source/KJH/\352\267\270\353\236\230\355\224\204\355\203\220\354\203\211/220606/bj7562.md" @@ -0,0 +1,76 @@ +## 나이트의 이동 + +class 만드는것 참고해서 만들어보았습니다. + +```java +import java.io.*; +import java.util.*; + +public class Main{ + static int l; + static int dx[] = {-2,-1,1,2,-2,-1,1,2}; + static int dy[] = {1,2,2,1,-1,-2,-2,-1}; + static Point now, goal; + public static void main(String[] args)throws IOException{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int T = Integer.parseInt(br.readLine()); + + + ArrayList arrlist = new ArrayList<>(); + + for(int i=0; i queue = new LinkedList<>(); + visited[p.r][p.c] = true; + queue.add(p); + + while(!queue.isEmpty()){ + Point tmp = queue.poll(); + int tmpX = tmp.r; + int tmpY = tmp.c; + int cnt = tmp.cnt; + + if(tmpX == goal.r && tmpY == goal.c){ + System.out.println(tmp.cnt); + return; + } + for(int i=0; i<8; i++){ + int nx = tmpX + dx[i]; + int ny = tmpY + dy[i]; + + if(nx >= 0 && nx < l && ny>= 0 && ny< l && !visited[nx][ny]){ + queue.add(new Point(nx, ny, cnt+1)); + visited[nx][ny] = true; + } + } + } + } + + static class Point{ + int r, c, cnt; + + public Point(int r, int c, int cnt){ + this.r = r; + this.c = c; + this.cnt = cnt; + } + } +} + +```