Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
a9de91b
[solved] boj9012
kimsz123456 Aug 4, 2024
ba2ca72
[solved] boj10773
kimsz123456 Aug 4, 2024
a935864
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
boriaegi Aug 5, 2024
70551c7
[solved] boj1874
boriaegi Aug 5, 2024
173b5d2
[solved] boj2841
kimsz123456 Aug 5, 2024
01cd0a0
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Aug 6, 2024
da291a0
[solved] boj2164
kimsz123456 Aug 6, 2024
31e0267
[solved] boj1158
kimsz123456 Aug 6, 2024
36d44d2
[solved] boj2346
kimsz123456 Aug 7, 2024
599be0b
[solved] boj1021
kimsz123456 Aug 10, 2024
8d234f1
[solved] boj13335
kimsz123456 Aug 11, 2024
5f7bc58
[solved] IM
kimsz123456 Aug 15, 2024
0db8388
[solved] IM
kimsz123456 Aug 18, 2024
820eead
[solved] boj17478
kimsz123456 Aug 20, 2024
1e72c39
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Aug 20, 2024
1d07954
[solved] boj24060.java
kimsz123456 Aug 21, 2024
0ab4cb6
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Aug 21, 2024
736be91
[solved] boj11729
kimsz123456 Aug 22, 2024
3415b3e
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Aug 22, 2024
ccfbb28
[solved] boj4779
bggiri Aug 25, 2024
e953dc7
[solved] boj2630
kimsz123456 Aug 26, 2024
d0142fd
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Aug 26, 2024
5d53b03
[solved] boj1992
kimsz123456 Aug 26, 2024
9486ed6
[solved] boj2447
kimsz123456 Aug 26, 2024
773ea2c
[solved] boj1074
kimsz123456 Aug 26, 2024
38eaa7e
Merge branch 'main' of https://github.com/SSAFY-12th-seoul-05-algorit…
kimsz123456 Sep 1, 2024
f9b8c65
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Sep 1, 2024
a84e42e
[solved] boj25418,boj2583,boj7562
kimsz123456 Sep 1, 2024
e392879
[solved] boj2178
kimsz123456 Sep 1, 2024
0f13d85
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Sep 2, 2024
7313504
[solved] boj7569
kimsz123456 Sep 2, 2024
005ea71
[solved] boj10026
kimsz123456 Sep 2, 2024
7427a40
[solved] boj1926
kimsz123456 Sep 2, 2024
93e1ae3
[solved] boj1260,24479,13023
kimsz123456 Sep 5, 2024
1e7a32b
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Sep 5, 2024
d31452c
[solved] boj1987,2606,4963
kimsz123456 Sep 10, 2024
d802a3e
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Sep 10, 2024
c9cd8d2
[solved] boj17472
kimsz123456 Sep 12, 2024
e263159
[solved] boj1063,13335-2,1417,14503,14891,16918,17135
kimsz123456 Sep 19, 2024
5d63601
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Sep 19, 2024
d2608c1
[solved] boj11000,1744,2170,2457
kimsz123456 Oct 7, 2024
05a07da
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Oct 7, 2024
a7e5c1b
[solved] boj2792
kimsz123456 Oct 8, 2024
e73e3f4
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Oct 8, 2024
5d05d5a
[solved] boj2230
kimsz123456 Oct 11, 2024
7d99383
[solved] boj1806
kimsz123456 Oct 11, 2024
21761dc
[solved] boj1644
kimsz123456 Oct 11, 2024
075b580
[solved] boj7453
kimsz123456 Oct 14, 2024
4c82f07
[solved] boj1351,1525,20166,2143
bggiri Oct 17, 2024
52bc1f4
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
bggiri Oct 17, 2024
000cc2a
[solved]
kimsz123456 Oct 21, 2024
cdbb497
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Oct 21, 2024
70585ce
[solved] boj21944
bggiri Oct 21, 2024
828a1c5
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
bggiri Oct 21, 2024
5ce5322
delete
kimsz123456 Oct 22, 2024
27160c6
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Oct 22, 2024
6a8fe30
Merge branch 'main' of https://github.com/SSAFY-12th-seoul-05-algorit…
kimsz123456 Oct 22, 2024
4f4c2ba
[solved] boj11003,13975,1655,1715
kimsz123456 Oct 22, 2024
2b03317
[solved]boj1707
kimsz123456 Oct 29, 2024
1244459
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Oct 29, 2024
356c6a2
[solved] boj1707
kimsz123456 Oct 29, 2024
da912dc
[solved] boj1043
kimsz123456 Oct 29, 2024
02ed003
[solved] boj5214
kimsz123456 Oct 29, 2024
787a235
[solved] boj2617
kimsz123456 Oct 30, 2024
be210a0
[solved] boj2887
kimsz123456 Oct 30, 2024
981fdd0
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Nov 4, 2024
1a57b0f
[solved] boj1068,1167,15681,1967
kimsz123456 Nov 4, 2024
09d1ee3
[solved]boj1197,1647,1774
kimsz123456 Nov 7, 2024
899fdc9
Merge branch 'js' of https://github.com/SSAFY-12th-seoul-05-algorithm…
kimsz123456 Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions jiseung/boj1197.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import java.util.*;
import java.io.*;

public class Main {

static class Edge implements Comparable<Edge> {
int num;
int w;

Edge(int num, int w) {
this.num = num;
this.w = w;
}

@Override
public int compareTo(Edge other) {
return Integer.compare(this.w, other.w);
}
}

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;

st = new StringTokenizer(br.readLine());

int V = Integer.parseInt(st.nextToken());
int E = Integer.parseInt(st.nextToken());

List<Edge>[] list = new ArrayList[V + 1];
boolean[] visited = new boolean[V + 1];

for(int i=1;i<=V;i++) {
list[i] = new ArrayList<>();
}

for (int i = 0; i < E; i++) {
st = new StringTokenizer(br.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int w = Integer.parseInt(st.nextToken());
list[a].add(new Edge(b, w));
list[b].add(new Edge(a, w));
}

PriorityQueue<Edge> pq = new PriorityQueue<>();

pq.add(new Edge(1, 0));
int result = 0;

while (!pq.isEmpty()) {
Edge now = pq.poll();
int num = now.num;
int w = now.w;

if(!visited[num]) {
visited[num]=true;
result +=w;
for(Edge next : list[num]) {
if(!visited[next.num]) {
pq.add(next);
}
}
}
}
System.out.println(result);
}
}
74 changes: 74 additions & 0 deletions jiseung/boj1647.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import java.util.*;
import java.io.*;

public class Main {

static class Node implements Comparable<Node> {
int end;
int w;

Node(int end, int w) {
this.end = end;
this.w = w;
}

@Override
public int compareTo(Node other) {
return Integer.compare(this.w, other.w);
}
}

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;

st = new StringTokenizer(br.readLine());

int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());

List<Node>[] list = new ArrayList[N + 1];
boolean[] visited = new boolean[N + 1];

for (int i = 0; i <= N; i++) {
list[i] = new ArrayList<>();
}


for (int i = 0; i < M; i++) {
st = new StringTokenizer(br.readLine());
int start = Integer.parseInt(st.nextToken());
int end = Integer.parseInt(st.nextToken());
int w = Integer.parseInt(st.nextToken());

list[start].add(new Node(end, w));
list[end].add(new Node(start, w));

}

PriorityQueue<Node> pq = new PriorityQueue<>();
pq.add(new Node(1, 0));

int result = 0;
int max = 0;
while (!pq.isEmpty()) {
Node now = pq.poll();
int end = now.end;
int w = now.w;

if (visited[end]) continue;

result += w;
max = Math.max(max, w);
visited[end] = true;

for (Node node : list[end]) {
if (!visited[node.end]) {
pq.add(node);
}
}
}

System.out.println(result-max);
}
}
69 changes: 69 additions & 0 deletions jiseung/boj1774.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import java.util.*;
import java.io.*;

public class Main {
static int[] parent;
static int[][] god;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;

st = new StringTokenizer(br.readLine());

int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());

god = new int[N+1][2];

for(int i=1;i<=N;i++) {
st = new StringTokenizer(br.readLine());
god[i][0] = Integer.parseInt(st.nextToken());
god[i][1] = Integer.parseInt(st.nextToken());
}

parent = new int[N+1];
for(int i=1;i<=N;i++) {
parent[i]=i;
}

for(int i=0;i<M;i++) {
st = new StringTokenizer(br.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
union(a,b);
}

List<double[]> list = new ArrayList<>();
for(int i=1;i<N;i++) {
for(int j = i+1;j<=N;j++) {
list.add(new double[] {i,j,dist(i,j)});
}
}
Collections.sort(list,(o1,o2)->o1[2]<o2[2]?-1:1);

double result=0;
for(int i=0;i<list.size();i++) {
if(union((int)list.get(i)[0],(int)list.get(i)[1])) {
result += list.get(i)[2];
}
}
System.out.println(String.format("%.2f",result));

}
static int find(int a) {
if(parent[a]==a) return a;
return parent[a]=find(parent[a]);
}

static boolean union(int a, int b) {
a = find(a);
b = find(b);
if(a==b) return false;
if(a<b) parent[b]=a;
else parent[a]=b;
return true;
}
static double dist(int a, int b) {
return Math.sqrt(Math.pow((god[a][0]-god[b][0]),2)+Math.pow((god[a][1]-god[b][1]),2));
}
}