Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit fff71eb

Browse files
committed
I dunno what happended
1 parent 69044f9 commit fff71eb

File tree

2 files changed

+56
-55
lines changed

2 files changed

+56
-55
lines changed

dining.out

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
11
1
2-
1
3-
1
4-
1
5-
1
6-
1
72
0
83
0
9-
1
10-
1
11-
1
12-
1
13-
1
14-
1
154
0
165
0
17-
1
18-
1
19-
1
20-
1
21-
1
22-
1
236
0
247
0
258
1
269
1
27-
1
28-
1
29-
1
30-
1
3110
0
3211
0
33-
1
34-
1
35-
1
36-
1
37-
1
38-
1
39-
1
4012
0
41-
1
42-
1
43-
1
44-
1
45-
1
46-
1
47-
1
13+
0
14+
0
4815
0
4916
1
5017
1
51-
1
52-
1
53-
1
54-
1
55-
1
18+
0
19+
0
20+
0
21+
0
22+
0
5623
0
5724
1
5825
1
26+
0
27+
0
28+
0
29+
0
30+
0
31+
0
5932
1
6033
1
34+
0
35+
0
36+
0
37+
0
38+
0
39+
0
40+
0
6141
1
42+
0
43+
0
44+
0
45+
0
46+
0
47+
0
48+
0
6249
1
50+
0
51+
0
52+
0
53+
0
54+
0
55+
0
56+
0
6357
1
58+
0
59+
0
60+
0
61+
0
62+
0
63+
0

src/dining.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ static int minDist(int dist[], boolean[] set1) {
1111
}
1212
return min_index;
1313
}
14-
static final int OFFSET = -1; // Offset by 1 for adjancey matirix because index begins at 0
14+
static final int OFFSET = -1; // 0 /*Remove offset*/ by 1 for adjancey matirix because index begins at 0
1515
public static int[] root;
1616
public static int status = -1;
1717
public static int[] arr;
1818
public static int[] pasture;
1919
//public static List<IPair> pastures = new ArrayList<IPair>();
2020
public static List<Integer> pastures = new ArrayList<Integer>();
2121
public static int[] dijkstra(int[][] graph1, int startVertex) {
22+
//Arrays.fill(root, 0);
2223
status = 0;
2324
int N = graph1.length;
2425
int[] dists = new int[N];
@@ -53,8 +54,8 @@ public static int[] dijkstra(int[][] graph1, int startVertex) {
5354
//if(pastures.contains(new IPair(nearestVertex,vertexIndex))) {
5455

5556
//if(pastures.contains(nearestVertex) ) {
56-
System.out.println("Info: "+nearestVertex+" "+vertexIndex);
57-
System.out.println("Set "+(nearestVertex - 1) + " and "+(vertexIndex - 1));
57+
//System.out.println("Info: "+nearestVertex+" "+vertexIndex);
58+
//System.out.println("Set "+(nearestVertex - 1) + " and "+(vertexIndex - 1));
5859
//arr[nearestVertex] = 1;
5960
//arr[vertexIndex] = 1;
6061
/*
@@ -85,7 +86,7 @@ public static void main(String[] args) throws IOException{
8586
int N = Integer.parseInt(st.nextToken());
8687
int M = Integer.parseInt(st.nextToken());
8788
int K = Integer.parseInt(st.nextToken());
88-
int[][] matrix = new int[N][N];
89+
int[][] matrix = new int[N+1][N+1];
8990
arr = new int[N];
9091
pasture = new int[N];
9192
for(int i = 0; i < N; i++){
@@ -94,44 +95,44 @@ public static void main(String[] args) throws IOException{
9495
for(int i = 0; i < M; i ++) {
9596
st = new StringTokenizer(f.readLine());
9697
int x = Integer.parseInt(st.nextToken()),y = Integer.parseInt(st.nextToken()),z = Integer.parseInt(st.nextToken());
97-
matrix[x + OFFSET][y + OFFSET] = z;
98-
matrix[y + OFFSET][x + OFFSET] = z;
98+
matrix[x + 0 /*Remove offset*/][y + 0 /*Remove offset*/] = z;
99+
matrix[y + 0 /*Remove offset*/][x + 0 /*Remove offset*/] = z;
99100
}
100101
//System.out.println(Arrays.deepToString(matrix).replaceAll("],*", "],\n"));
101102
// Dijkstra Modification begins here
102-
int[] out = dijkstra(matrix, N-2);
103+
int[] out = dijkstra(matrix, N-1);
103104
for(int i = 0; i < K; i++) {
104105
st = new StringTokenizer(f.readLine());
105106
int x = Integer.parseInt(st.nextToken());
106107
int y = Integer.parseInt(st.nextToken());
107-
pasture[x-1] = y;
108-
x = x + OFFSET;
108+
//pasture[x-1] = y;
109+
x = x + 0 /*Remove offset*/;
109110
for(int j = 0; j < N; j++) {
110111
if(matrix[j][x] != 0) {
111112
//System.out.println("Override 1 "+j+" "+x+" "+y);
112-
matrix[j][x] = matrix[j][x] - y;
113+
matrix[j][x] = out[x] - y;
113114
}
114115
if(matrix[x][j] != 0) {
115116
//System.out.println("Override 2 "+x+" "+j+" "+y);
116-
matrix[x][j] = matrix[x][j] - y;
117+
matrix[x][j] = out[x] - y;
117118
}
118119

119120
}
120-
pastures.add(x);
121+
//pastures.add(x);
121122
//pastures.add(new IPair(x,y));
122123

123124
}
124125
// End modification
125126
System.out.println("Modifacation Complete");
126-
System.out.println(Arrays.deepToString(matrix).replaceAll("],*", "],\n"));
127-
int[] out2 = dijkstra(matrix, N-1);
127+
//System.out.println(Arrays.deepToString(matrix).replaceAll("],*", "],\n"));
128+
int[] out2 = dijkstra(matrix, N);
128129

129130
//System.out.println(Arrays.toString(root));
130131
//System.out.println(Arrays.toString(out));
131132

132133
PrintWriter pw = new PrintWriter(new FileWriter("dining.out"));
133134
for(int k = 0; k < arr.length -1; k ++) {
134-
if(out[k] <= out2[k]) {
135+
if(out[k] >= out2[k]) {
135136
pw.println("1");
136137
}else {
137138
pw.println("0");

0 commit comments

Comments
 (0)