Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 43,746 MiB 0,000 s OK
#2 10/10 50,980 MiB 0,028 s OK
#3 10/10 48,152 MiB 0,034 s OK
#4 10/10 95,418 MiB 1,300 s OK
#5 0/10 411,316 MiB 10,722 s Prekoračen čas
#6 0/10 85,141 MiB 2,435 s Napačen odgovor
Tvoj izhod:
​0
<<<EOF>>>
Pravilen izhod:
​2591567982003000
<<<EOF>>>
#7 0/10 436,859 MiB 10,837 s Prekoračen čas
#8 0/10 442,754 MiB 10,825 s Prekoračen čas
#9 0/10 445,492 MiB 10,911 s Prekoračen čas
#10 0/10 369,551 MiB 10,895 s Prekoračen čas

Ocenjevani program (Crte.java):
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Crte {

    static class Tocka {
        int x;
        int y;

        public Tocka(int x, int y) {
            this.x = x;
            this.y = y;
        }

        int razdalja(Tocka t) {
            return (x-t.x)*(x-t.x) + (y-t.y)*(y-t.y);
        }
    }

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();

        Tocka []tocke = new Tocka[n];
        for (int i = 0; i < n; i++) {
            tocke[i] = new Tocka(scanner.nextInt(), scanner.nextInt());
        }

        Map<Integer, Integer> map = new TreeMap<>();
        
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                int razdalja = tocke[i].razdalja(tocke[j]);
                if(razdalja != 0) {
                    Integer curr = map.get(razdalja);
                    curr = curr == null ? 0 : curr;
                    curr++;
                    map.put(razdalja, curr);
                }
            }
        }

        int r = 0;
        for (Integer i : map.values()) {
            r+= i * (i-1) / 2;
        }
        System.out.println(r);
    }
}

/*

10
0 18
13 5
14 19
18 2
6 17
6 7
0 2
1 19
6 11
0 9

 */

/*

0
338
197
580
37
157
256
2
85
81
0
197
34
193
53
178
340
85
185
0
305
68
208
485
169
128
296
0
369
169
324
578
225
373
0
100
261
29
36
100
0
61
169
16
40
0
290
117
49
0
89
101
0
40
0

 */