Go to diff to previous submission
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { while ((str = reader.readLine()) != null) { List<Point> points = new ArrayList<Point>(); for (int i = 0; i < numLines; i++) { } boolean correct = false; boolean keepLoop = true; for (int i = 0; i < points.size(); i++) { point.connections++; for (int j = i; j < points.size(); j++) { if (point2.number == point.number && point2.connectedWith != point.connectedWith) { point.connections += 1; if (point.connections == 4) { correct = true; keepLoop = false; break; } } } if (!keepLoop) break; } // for (int i = 0; i < points.size(); i++) { // if (points.get(i).getConnections() == 4) { // correct=true; // } // } if (correct) { } else { } } } int number = 0; int connectedWith = 0; int connections = 0; this.number = number; this.connectedWith = connectedWith; } void setConnections(int connections) { this.connections = connections; } int getConnections() { return this.connections; } } }
--- c5.s915.cteam061.fn.java.0.Main.java +++ c5.s927.cteam061.fn.java.0.Main.java @@ -25,4 +25,6 @@ points.add(new Point(y, x)); } + boolean correct = false; + boolean keepLoop = true; for (int i = 0; i < points.size(); i++) { Point point = points.get(i); @@ -32,14 +34,19 @@ if (point2.number == point.number && point2.connectedWith != point.connectedWith) { point.connections += 1; + if (point.connections == 4) { + correct = true; + keepLoop = false; + break; + } } } - System.out.println(point.connections); - } - boolean correct = false; - for (int i =0; i < points.size(); i++) { - if (points.get(i).getConnections() == 4) { - correct=true; - } + if (!keepLoop) break; } + +// for (int i = 0; i < points.size(); i++) { +// if (points.get(i).getConnections() == 4) { +// correct=true; +// } +// } if (correct) { System.out.println("YES");