@@ -62,6 +62,7 @@ public static void main(String[] args) throws IOException{
62
62
points .add (b );
63
63
segements .add (new LineSegement (a , b ));
64
64
}
65
+ f .close ();
65
66
points .sort (null );
66
67
// Algorthim
67
68
int size = points .size ();
@@ -70,8 +71,8 @@ public static void main(String[] args) throws IOException{
70
71
//System.out.println(points.get(i));
71
72
}
72
73
for (int i =0 ; i < N ; i ++) {
73
- // System.out.println(Arrays.toString(lookup[i]));
74
- // System.out.println(segements.get(i));
74
+ System .out .println (Arrays .toString (lookup [i ]));
75
+ System .out .println (segements .get (i ));
75
76
}
76
77
77
78
int currentY = -1 ;
@@ -90,7 +91,7 @@ public static void main(String[] args) throws IOException{
90
91
}else {
91
92
*/
92
93
int state = num (p .index ,p ,lookup );
93
- // System.out.println("Endpoint "+ state + " "+p);
94
+ System .out .println ("Endpoint " + state + " " +p );
94
95
if (state == 0 ) {
95
96
pz .add (p .index );
96
97
}else if (state == 1 ) {
@@ -105,8 +106,8 @@ public static void main(String[] args) throws IOException{
105
106
//if(j == k){
106
107
// continue;
107
108
//}
108
- if (Point .intersection (segements .get (j ) ,segements .get (k ))) {
109
- // System.out.println("Intersectsion at "+segements.get(j)+" -|||- "+segements.get(k));
109
+ if (Point .intersection (segements .get (pz . get ( j )) ,segements .get (pz . get ( k ) ))) {
110
+ System .out .println ("Intersectsion at " +segements .get (j )+" -|||- " +segements .get (k ));
110
111
tbl [i ] ++;
111
112
tbl [j ] ++;
112
113
if (tbl [i ] > max ) {
@@ -123,7 +124,7 @@ public static void main(String[] args) throws IOException{
123
124
//}
124
125
}
125
126
// File Writting
126
- // System.out.println(max + " " + maxi + " " + Arrays.toString(tbl));
127
+ System .out .println (max + " " + maxi + " " + Arrays .toString (tbl ));
127
128
PrintWriter pw = new PrintWriter (new BufferedWriter (new FileWriter ("cowjump.out" )));
128
129
pw .println (max + 1 );
129
130
pw .close ();
@@ -176,7 +177,7 @@ static boolean intersection(LineSegement a,LineSegement b) {
176
177
return intersection (a .a , a .b , b .a , b .b );
177
178
}
178
179
public String toString () {
179
- return "| (" +this .x + "," + this .y + ") INDEX " +this .index + " | " ;
180
+ return "(" +this .x + "," + this .y + ", " +this .index + ") " ;
180
181
}
181
182
boolean eq (Point q ) {
182
183
if (q .x == this .x && q .y == this .y ) {
@@ -186,7 +187,14 @@ boolean eq(Point q) {
186
187
}
187
188
@ Override
188
189
public int compareTo (Point arg0 ) {
189
- return Double .compare (this .x , arg0 .x );
190
+ if (arg0 .x == this .x ) {
191
+ return Double .compare (this .y , this .y );
192
+ }else if (this .x < arg0 .x ) {
193
+ return -1 ;
194
+ }else {
195
+ return 1 ;
196
+ }
197
+ //return Double.compare(this.x, arg0.x);
190
198
//return 0;
191
199
}
192
200
}
@@ -197,8 +205,8 @@ public LineSegement(Point a,Point b) {
197
205
this .a = b ;
198
206
this .b = a ;
199
207
}else {
200
- this .a = a ;
201
- this .b = b ;
208
+ this .a = a ;
209
+ this .b = b ;
202
210
}
203
211
204
212
}
0 commit comments