Rezultati

Up. imeNalogaJezikRezultatČas oddaje
iota-2017 Črte Java 0/100Prekoračen čas (TLE) 20. apr '17 @ 20:12

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 45,121 MiB 0,000 s OK
#2 0/10 49,379 MiB 10,913 s Prekoračen čas
#3 0/10 46,246 MiB 10,872 s Prekoračen čas
#4 0/10 72,879 MiB 10,836 s Prekoračen čas
#5 0/10 70,750 MiB 10,857 s Prekoračen čas
#6 0/10 69,355 MiB 10,873 s Prekoračen čas
#7 0/10 73,816 MiB 10,790 s Prekoračen čas
#8 0/10 69,492 MiB 10,825 s Prekoračen čas
#9 0/10 70,266 MiB 10,859 s Prekoračen čas
#10 0/10 71,148 MiB 10,822 s Prekoračen čas

Ocenjevani program (LineSegmentsMain.java):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by iota-2017 on 4/20/17.
 */
public class LineSegmentsMain {
    public static void main(String[] args) {
        List<Integer[]> points = new LinkedList<Integer[]>();
        List<Double> lengths = new LinkedList<Double>();
        int k = 0;
        BufferedReader in
                = new BufferedReader(new InputStreamReader(System.in));
        try {
            int nmbOfPoints = Integer.valueOf(in.readLine());
            for (int i =0; i<nmbOfPoints;i++){
                String strLine = in.readLine();
                String[] coords = strLine.split(" ");
                Integer[] arr = {Integer.valueOf(coords[0]), Integer.valueOf(coords[1])};
                points.add(arr);

            }

            int i=0;
            while (!points.isEmpty()) {
                int j = 0;
                while (j<points.size()){
                    if (j!=i){
                        lengths.add(Math.sqrt(Math.pow((points.get(j)[1] - points.get(i)[1]),2)+Math.pow((points.get(j)[0]-points.get(i)[0]),2)));
                    }
                    j++;
                }
                points.remove(points.get(i));
            }
            while (!lengths.isEmpty()) {
                int j = 0;
                while (j<lengths.size()){
                    if (j!=i){
                        if (lengths.get(i).equals(lengths.get(j))){
                            k++;
                        }
                    }
                    j++;
                }
                lengths.remove(lengths.get(i));
            }
            System.out.println(k);


        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}