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

Commit 9e10ad8

Browse files
authored
Add files via upload
1 parent 31463a9 commit 9e10ad8

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

Java/bin/Position.class

0 Bytes
Binary file not shown.

Java/bin/Structure.class

0 Bytes
Binary file not shown.

Java/bin/perimeter.class

-95 Bytes
Binary file not shown.

Java/perimeter.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
13 37
1+
13 22

Java/src/perimeter.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
public class perimeter {
55
public static int N;
66
public static boolean[][] grid;
7+
public static boolean[][] visit;
78
public static boolean within(int x,int y,boolean[][] grid) {
89
return true;
910
/*
@@ -16,6 +17,7 @@ public static boolean within(int x,int y,boolean[][] grid) {
1617
*/
1718
}
1819
public static Structure flood(int x,int y, int i) {
20+
1921
Structure st = new Structure(i);
2022
Queue<Position> q = new LinkedList<Position>();
2123
q.add(new Position(x,y));
@@ -26,7 +28,7 @@ public static Structure flood(int x,int y, int i) {
2628
try {
2729

2830
//System.out.println("FILL ("+x1+","+y1+")");
29-
if(grid[x1][y1]) {
31+
if(!visit[x1][y1]) {
3032
if(x1 < N && grid[x1 + 1][y1]) {
3133
q.add(new Position(x1 + 1,y1));
3234
}
@@ -46,7 +48,7 @@ public static Structure flood(int x,int y, int i) {
4648
continue;
4749
}
4850
st.addStruct(p);
49-
grid[p.x][p.y] = false; // TODO remove to prevent intefering with addStruct
51+
visit[p.x][p.y] = true;
5052

5153
}
5254
return st;
@@ -58,6 +60,7 @@ public static void main(String[] args) throws IOException{
5860
int size = N+2;
5961
int iter_size = N+1;
6062
grid = new boolean[size][size];
63+
visit = new boolean[size][size];
6164
for(int i = 1; i < iter_size; i ++) {
6265
String str = f.readLine();
6366
for(int j = 1; j < iter_size; j ++) {
@@ -88,8 +91,8 @@ public static void main(String[] args) throws IOException{
8891
//struct.toggleAll();
8992
//struct.perimeterList.removeAll(struct.posList);
9093
int area = struct.posList.size();
91-
System.out.println("1:"+struct.posList);
92-
System.out.println("2:"+struct.perimeterList);
94+
//System.out.println("1:"+struct.posList);
95+
//System.out.println("2:"+struct.perimeterList);
9396
if(area > largestArea) {
9497
largestArea = area;
9598
perimOfLarge = struct.perimeterList.size();

0 commit comments

Comments
 (0)