From 36c53a9cdb00334a7ebc016fd905b08b1beb6a1a Mon Sep 17 00:00:00 2001 From: Myeongjin Kim Date: Sun, 24 Apr 2022 00:05:04 +0900 Subject: [PATCH 1/4] 220424 kmj --- .DS_Store | Bin 0 -> 6148 bytes source/.DS_Store | Bin 0 -> 6148 bytes source/KMJ/.DS_Store | Bin 0 -> 6148 bytes source/KMJ/bj1260.md | 92 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 .DS_Store create mode 100644 source/.DS_Store create mode 100644 source/KMJ/.DS_Store create mode 100644 source/KMJ/bj1260.md diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f16c430e3848a759bfd804b0af7560b4f5930147 GIT binary patch literal 6148 zcmeHKO;6iE5S~CBh9|q*%{mOq}}xpk!X&hcSL0(a-odQCWb!@CKM-Irot36l%;FR_X8t*j&iW^cG#EBSTyqbviKf&a+>pAR0C(KncDR7VE})dBz= zxRtiUvDa2L34nkAa`7eEbLf&8vCuqd#UO#R4$axSie5#mZfO3+>IJ%|zEyoUt(MJtqn_5e|GFtlXQ_BQdObNkc$S^E z+SNDO&HX^sipt)p9uaZ(>^sMZVK5L31Ovgqzh?kBTckKNj6N6$27-Yt1M)s3G{NlH z8tT)5PD=pb7|SXc>(4(h$pSDtwuV@Nu(<-wmA%AZuN~Ojq0esL8k#$??u7QRSuhX`{4oZ2Tvp`_m-5`&yPo9Qgm#N2 tB6h6|AQ)>Z25KtCMBb5ORhmA@82aqk8cGydS9f6i2q+=Z1p`08zz3$zL|Fg; literal 0 HcmV?d00001 diff --git a/source/KMJ/.DS_Store b/source/KMJ/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d33ea65f3b7e44c241074ce9ddf2d58b4a512d42 GIT binary patch literal 6148 zcmeHKyG{c!5S)b+K{QuV`U?=Dpthn=Q1b)mNQHt@(O<=P@ntoC zW6M+A-U6`o%XS3}0G4z|y!tRV-*=zcNkxoE=NUJ+!X=)uz1z*Qj|ZH4h7nI#;rc6o z|2XdUBX@`QZ+843MWuigkOERb3P^!pDd4r2wmeVNC*bAq`_;hfH z7J#^5IE?e?C5X)f#9lZhGD5SY5|e7xVp!4{Z~aHzm(E(fpwxAY(S|3i{iQa}p)D+O$^x!QsA!@_yBA-BWnNv literal 0 HcmV?d00001 diff --git a/source/KMJ/bj1260.md b/source/KMJ/bj1260.md new file mode 100644 index 0000000..51167c3 --- /dev/null +++ b/source/KMJ/bj1260.md @@ -0,0 +1,92 @@ + + + +## bj + +```java +//package p1260; //error occurs + +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Queue; +import java.util.Scanner; + +public class DFS_BFS { + + //DFS 구현 + public static void dfs(int start, LinkedList[] adj, boolean[] visited) { + visited[start] = true; + System.out.print(start + " "); + + Iterator iter = adj[start].listIterator(); + while (iter.hasNext()) { + int nextStart = iter.next(); + if (!visited[nextStart]) { + dfs(nextStart, adj, visited); + } + + } + + } + //BFS 구현 - bfs는 queue(FIFO 형식)로 구현 + public static void bfs(int start, LinkedList[] adj, boolean[] visited) { + + Queue queue = new LinkedList(); + visited[start] = true; + queue.add(start); // queue에 값 넣기 + + while (queue.size() != 0) { + start = queue.poll(); // queue의 첫 번째 값 꺼내기 + System.out.print(start + " "); + + Iterator iter = adj[start].listIterator(); + while (iter.hasNext()) { // 인접한 정점 존재하면 + int nextStart = iter.next(); + if (!visited[nextStart]) { + visited[nextStart] = true; + queue.add(nextStart); // queue에 값 넣기 + } + } + } + } + + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + + int n = sc.nextInt(); // 정점 개수 + int m = sc.nextInt(); // 간선 개수 + int v = sc.nextInt(); // 시작 정점 번호 + + boolean[] visited = new boolean[n + 1]; // 방문 확인 배열 + + LinkedList[] adjList = new LinkedList[n + 1]; // adjacent list로 표현 + + for (int i = 0; i <= n; i++) { //각 인접노드와 연결된 노드도 linked list로 정의 + adjList[i] = new LinkedList(); + } + + for (int i = 0; i < m; i++) { // 간선 입력 및 저장 + int m1 = sc.nextInt(); + int m2 = sc.nextInt(); + adjList[m1].add(m2); // 양방향 + adjList[m2].add(m1); + } + + for (int i = 1; i <= n; i++) { // 정점 번호 오름차순 배치 + Collections.sort(adjList[i]); + } + + dfs(v, adjList, visited); // dfs 실행 + + for (int i = 0; i <= n; i++) { //array 초기화 + visited[i] = false; + } + + System.out.println(); + + bfs(v, adjList, visited); // bfs 실행 + } +} +``` From cba4bc84d1b976e12edc03552ae5eecd70856f91 Mon Sep 17 00:00:00 2001 From: Myeongjin Kim Date: Sun, 24 Apr 2022 00:17:20 +0900 Subject: [PATCH 2/4] test --- source/KMJ/.DS_Store | Bin 6148 -> 0 bytes source/KMJ/bj1260.md | 92 ------------------------------------------- 2 files changed, 92 deletions(-) delete mode 100644 source/KMJ/.DS_Store delete mode 100644 source/KMJ/bj1260.md diff --git a/source/KMJ/.DS_Store b/source/KMJ/.DS_Store deleted file mode 100644 index d33ea65f3b7e44c241074ce9ddf2d58b4a512d42..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyG{c!5S)b+K{QuV`U?=Dpthn=Q1b)mNQHt@(O<=P@ntoC zW6M+A-U6`o%XS3}0G4z|y!tRV-*=zcNkxoE=NUJ+!X=)uz1z*Qj|ZH4h7nI#;rc6o z|2XdUBX@`QZ+843MWuigkOERb3P^!pDd4r2wmeVNC*bAq`_;hfH z7J#^5IE?e?C5X)f#9lZhGD5SY5|e7xVp!4{Z~aHzm(E(fpwxAY(S|3i{iQa}p)D+O$^x!QsA!@_yBA-BWnNv diff --git a/source/KMJ/bj1260.md b/source/KMJ/bj1260.md deleted file mode 100644 index 51167c3..0000000 --- a/source/KMJ/bj1260.md +++ /dev/null @@ -1,92 +0,0 @@ - - - -## bj - -```java -//package p1260; //error occurs - -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Queue; -import java.util.Scanner; - -public class DFS_BFS { - - //DFS 구현 - public static void dfs(int start, LinkedList[] adj, boolean[] visited) { - visited[start] = true; - System.out.print(start + " "); - - Iterator iter = adj[start].listIterator(); - while (iter.hasNext()) { - int nextStart = iter.next(); - if (!visited[nextStart]) { - dfs(nextStart, adj, visited); - } - - } - - } - //BFS 구현 - bfs는 queue(FIFO 형식)로 구현 - public static void bfs(int start, LinkedList[] adj, boolean[] visited) { - - Queue queue = new LinkedList(); - visited[start] = true; - queue.add(start); // queue에 값 넣기 - - while (queue.size() != 0) { - start = queue.poll(); // queue의 첫 번째 값 꺼내기 - System.out.print(start + " "); - - Iterator iter = adj[start].listIterator(); - while (iter.hasNext()) { // 인접한 정점 존재하면 - int nextStart = iter.next(); - if (!visited[nextStart]) { - visited[nextStart] = true; - queue.add(nextStart); // queue에 값 넣기 - } - } - } - } - - public static void main(String[] args) { - - Scanner sc = new Scanner(System.in); - - int n = sc.nextInt(); // 정점 개수 - int m = sc.nextInt(); // 간선 개수 - int v = sc.nextInt(); // 시작 정점 번호 - - boolean[] visited = new boolean[n + 1]; // 방문 확인 배열 - - LinkedList[] adjList = new LinkedList[n + 1]; // adjacent list로 표현 - - for (int i = 0; i <= n; i++) { //각 인접노드와 연결된 노드도 linked list로 정의 - adjList[i] = new LinkedList(); - } - - for (int i = 0; i < m; i++) { // 간선 입력 및 저장 - int m1 = sc.nextInt(); - int m2 = sc.nextInt(); - adjList[m1].add(m2); // 양방향 - adjList[m2].add(m1); - } - - for (int i = 1; i <= n; i++) { // 정점 번호 오름차순 배치 - Collections.sort(adjList[i]); - } - - dfs(v, adjList, visited); // dfs 실행 - - for (int i = 0; i <= n; i++) { //array 초기화 - visited[i] = false; - } - - System.out.println(); - - bfs(v, adjList, visited); // bfs 실행 - } -} -``` From e12aadda5ee7a5f127f0fd54637049a59197e139 Mon Sep 17 00:00:00 2001 From: Myeongjin Kim Date: Sun, 24 Apr 2022 00:34:14 +0900 Subject: [PATCH 3/4] 220424 kmj --- source/.DS_Store | Bin 6148 -> 6148 bytes source/KMJ/.DS_Store | Bin 0 -> 6148 bytes source/KMJ/bj1260.md | 92 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 source/KMJ/.DS_Store create mode 100644 source/KMJ/bj1260.md diff --git a/source/.DS_Store b/source/.DS_Store index cdd7c0413ab19ed7adcab1f94a0a9c44ffc7c109..810e1f0dd60e83c4cfb50929b12f5890a8d58c86 100644 GIT binary patch delta 309 zcmZoMXfc=|#>B)qu~2NHo+2aX#DLw4m>3y3C-X4c)id%kFfh3M2Lm9Bfq|L9o57dC zE2+G=ASow52`I87sURn_xWvHV8Y2@k3o9Et2RjEhM{ICLetB?7Vo7PSQ({pxh!>Kd zpOXY*Cnkkurk2MGh&boxl_X~7r51rTWTvD7mBfT+=B4D9JLSig=A{&aH3vgvI5;^t z;{_zDt4%G9bQDZ1EoyZXsx6HSfNW#4+FDKyQDuGWp!n>Z+`RlQu!9*G86h+S$ScU8 zdvXM0sUX-pWx+*xIr(|%KxxL!Cm5qyHnVf^a{vQn^GC+-%#-;=EIELtfDPIlAhLxS E0FZc6YXATM delta 86 zcmZoMXfc=|#>B`mu~2NHo+2ar#DLw5?2~zz?D!Z?FfcG|_zwmQ43pKEOE+(14rAH; mfcXjIW_AvK4xp~h7n#2^Pv#e~+ml?MJ diff --git a/source/KMJ/.DS_Store b/source/KMJ/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3517a3b52657fd64a72cc99589c54c91daba98da GIT binary patch literal 6148 zcmeHKyG{c!5S)b+K{P2T{RN0nP+L(bsA(wCkqQN+N`Do9!hi5*F#8Z9x**Zepjl}> z_Ik&br?|ZZV5|LR2`m82>5h2yVQRkbKCzRE7?I91Zg7Q5ykK*;on#*mIQI+#p0ULB zcmD2a*zN}I@>qK#K75oNKS)t2AO)m=6p#W^;8zNG?WN7n6E#W!DIf*D6!7muqdWG( zF)=9Dw&=hV$s9g4;6 zjJHUK^+b(QKnffxaGJ}7*Z*7k5B>ikNh>KJ1^$%+He27XSA0^{*2&|%);9Vh-E-dQ rZkz{&LzH7;lw&Tu9A89I<~5&lzZZ^)L1#SZMEwl7E;1?b*9v?BtT`NU literal 0 HcmV?d00001 diff --git a/source/KMJ/bj1260.md b/source/KMJ/bj1260.md new file mode 100644 index 0000000..51167c3 --- /dev/null +++ b/source/KMJ/bj1260.md @@ -0,0 +1,92 @@ + + + +## bj + +```java +//package p1260; //error occurs + +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Queue; +import java.util.Scanner; + +public class DFS_BFS { + + //DFS 구현 + public static void dfs(int start, LinkedList[] adj, boolean[] visited) { + visited[start] = true; + System.out.print(start + " "); + + Iterator iter = adj[start].listIterator(); + while (iter.hasNext()) { + int nextStart = iter.next(); + if (!visited[nextStart]) { + dfs(nextStart, adj, visited); + } + + } + + } + //BFS 구현 - bfs는 queue(FIFO 형식)로 구현 + public static void bfs(int start, LinkedList[] adj, boolean[] visited) { + + Queue queue = new LinkedList(); + visited[start] = true; + queue.add(start); // queue에 값 넣기 + + while (queue.size() != 0) { + start = queue.poll(); // queue의 첫 번째 값 꺼내기 + System.out.print(start + " "); + + Iterator iter = adj[start].listIterator(); + while (iter.hasNext()) { // 인접한 정점 존재하면 + int nextStart = iter.next(); + if (!visited[nextStart]) { + visited[nextStart] = true; + queue.add(nextStart); // queue에 값 넣기 + } + } + } + } + + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + + int n = sc.nextInt(); // 정점 개수 + int m = sc.nextInt(); // 간선 개수 + int v = sc.nextInt(); // 시작 정점 번호 + + boolean[] visited = new boolean[n + 1]; // 방문 확인 배열 + + LinkedList[] adjList = new LinkedList[n + 1]; // adjacent list로 표현 + + for (int i = 0; i <= n; i++) { //각 인접노드와 연결된 노드도 linked list로 정의 + adjList[i] = new LinkedList(); + } + + for (int i = 0; i < m; i++) { // 간선 입력 및 저장 + int m1 = sc.nextInt(); + int m2 = sc.nextInt(); + adjList[m1].add(m2); // 양방향 + adjList[m2].add(m1); + } + + for (int i = 1; i <= n; i++) { // 정점 번호 오름차순 배치 + Collections.sort(adjList[i]); + } + + dfs(v, adjList, visited); // dfs 실행 + + for (int i = 0; i <= n; i++) { //array 초기화 + visited[i] = false; + } + + System.out.println(); + + bfs(v, adjList, visited); // bfs 실행 + } +} +``` From 63ebf80a628c202b20d6121ad59d248246b78a5e Mon Sep 17 00:00:00 2001 From: Myeongjin Kim Date: Sun, 24 Apr 2022 00:48:18 +0900 Subject: [PATCH 4/4] .DS_Store is banished --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 1 + source/.DS_Store | Bin 6148 -> 0 bytes source/KMJ/.DS_Store | Bin 6148 -> 0 bytes 4 files changed, 1 insertion(+) delete mode 100644 .DS_Store create mode 100644 .gitignore delete mode 100644 source/.DS_Store delete mode 100644 source/KMJ/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index f16c430e3848a759bfd804b0af7560b4f5930147..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKO;6iE5S~CBh9|q*%{mOq}}xpk!X&hcSL0(a-odQCWb!@CKM-Irot36l%;FR_X8t*j&iW^cG#EBSTyqbviKf&a+>pAR0C(KncDR7VE})dBz= zxRtiUvDa2L34nkAa`7eE2?& z#kiXly`c@r(jHu1KF^BOOxtEsq$3*}JADH@<9bU;D(o zompV*DvWWZo+^t z@c%Ht=R<(T7 diff --git a/source/KMJ/.DS_Store b/source/KMJ/.DS_Store deleted file mode 100644 index 3517a3b52657fd64a72cc99589c54c91daba98da..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyG{c!5S)b+K{P2T{RN0nP+L(bsA(wCkqQN+N`Do9!hi5*F#8Z9x**Zepjl}> z_Ik&br?|ZZV5|LR2`m82>5h2yVQRkbKCzRE7?I91Zg7Q5ykK*;on#*mIQI+#p0ULB zcmD2a*zN}I@>qK#K75oNKS)t2AO)m=6p#W^;8zNG?WN7n6E#W!DIf*D6!7muqdWG( zF)=9Dw&=hV$s9g4;6 zjJHUK^+b(QKnffxaGJ}7*Z*7k5B>ikNh>KJ1^$%+He27XSA0^{*2&|%);9Vh-E-dQ rZkz{&LzH7;lw&Tu9A89I<~5&lzZZ^)L1#SZMEwl7E;1?b*9v?BtT`NU