結果

問題 No.2769 Number of Rhombi
ユーザー tentententen
提出日時 2024-06-04 18:00:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,943 bytes
コンパイル時間 3,464 ms
コンパイル使用メモリ 79,268 KB
実行使用メモリ 458,616 KB
最終ジャッジ日時 2024-06-04 18:02:15
合計ジャッジ時間 105,921 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
37,012 KB
testcase_01 AC 51 ms
37,012 KB
testcase_02 AC 52 ms
36,780 KB
testcase_03 AC 2,371 ms
252,948 KB
testcase_04 AC 1,908 ms
198,024 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 4,384 ms
442,568 KB
testcase_23 AC 4,288 ms
458,616 KB
testcase_24 AC 49 ms
37,156 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        Point[] points = new Point[n];
        Map<Long, Map<Integer, Set<Integer>>> lines = new HashMap<>();
        for (int i = 0; i < n; i++) {
            points[i] = new Point(sc.nextInt(), sc.nextInt());
            for (int j = 0; j < i; j++) {
                long d = points[i].getDistance(points[j]);
                if (!lines.containsKey(d)) {
                    lines.put(d, new HashMap<>());
                }
                if (!lines.get(d).containsKey(j)) {
                    lines.get(d).put(j, new HashSet<>());
                }
                lines.get(d).get(j).add(i);
                if (!lines.get(d).containsKey(i)) {
                    lines.get(d).put(i, new HashSet<>());
                }
                lines.get(d).get(i).add(j);
            }
        }
        int ans = 0;
        for (Map<Integer, Set<Integer>> current : lines.values()) {
            for (int x : current.keySet()) {
                for (int y : current.get(x)) {
                    if (x >= y) {
                        continue;
                    }
                    for (int z : current.get(x)) {
                        if (y >= z) {
                            continue;
                        }
                        for (int k : current.get(y)) {
                            if (k != x && current.get(z).contains(k)) {
                                ans++;
                            }
                        }
                    }
                }
            }
        }
        System.out.println(ans);
    }
    
    static class Point {
        long x;
        long y;
        
        public Point(long x, long y) {
            this.x = x;
            this.y = y;
        }
        
        public long getDistance(Point p) {
            return (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y);
        }
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0