結果

問題 No.2769 Number of Rhombi
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-05-31 23:20:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,133 ms / 5,000 ms
コード長 1,789 bytes
コンパイル時間 2,415 ms
コンパイル使用メモリ 210,940 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-31 23:21:17
合計ジャッジ時間 35,530 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1,079 ms
6,940 KB
testcase_04 AC 968 ms
6,944 KB
testcase_05 AC 608 ms
6,940 KB
testcase_06 AC 830 ms
6,944 KB
testcase_07 AC 1,117 ms
6,944 KB
testcase_08 AC 1,133 ms
6,940 KB
testcase_09 AC 1,109 ms
6,940 KB
testcase_10 AC 1,076 ms
6,944 KB
testcase_11 AC 1,058 ms
6,944 KB
testcase_12 AC 1,023 ms
6,940 KB
testcase_13 AC 987 ms
6,940 KB
testcase_14 AC 967 ms
6,940 KB
testcase_15 AC 989 ms
6,944 KB
testcase_16 AC 986 ms
6,940 KB
testcase_17 AC 986 ms
6,940 KB
testcase_18 AC 981 ms
6,940 KB
testcase_19 AC 953 ms
6,940 KB
testcase_20 AC 978 ms
6,940 KB
testcase_21 AC 978 ms
6,944 KB
testcase_22 AC 977 ms
6,940 KB
testcase_23 AC 969 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 1,009 ms
6,940 KB
testcase_26 AC 998 ms
6,940 KB
testcase_27 AC 982 ms
6,940 KB
testcase_28 AC 960 ms
6,944 KB
testcase_29 AC 968 ms
6,940 KB
testcase_30 AC 990 ms
6,944 KB
testcase_31 AC 1,025 ms
6,940 KB
testcase_32 AC 1,126 ms
6,940 KB
testcase_33 AC 1,098 ms
6,944 KB
testcase_34 AC 1,081 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}
using Point = pair<long long, long long>;
Point calc(Point p1, Point p2, Point p3) {
    long long dx1 = p2.first - p1.first;
    long long dy1 = p2.second - p1.second;
    long long dx2 = p3.first - p1.first;
    long long dy2 = p3.second - p1.second;
    return {p1.first + dx1 + dx2, p1.second + dy1 + dy2};
}
long long dist(Point p1, Point p2) {
    long long dx = p1.first - p2.first;
    long long dy = p1.second - p2.second;
    return dx * dx + dy * dy;
}
int main() {
    fast_io();
    int n;
    cin >> n;
    vector<Point> xy(n);
    for (long long i = 0; i < n; i++) {
        cin >> xy[i].first >> xy[i].second;
    }
    set<Point> st(xy.begin(), xy.end());
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
        auto [x1, y1] = xy[i];
        for (long long j = i + 1; j < n; j++) {
            auto [x2, y2] = xy[j];
            for (long long k = j + 1; k < n; k++) {
                auto [x3, y3] = xy[k];
                auto p1 = xy[i];
                auto p2 = xy[j];
                auto p3 = xy[k];
                auto p4 = calc({x1, y1}, {x2, y2}, {x3, y3});
                if (dist(p2, p1) == dist(p3, p1) && st.count(p4) && p4 != p1) {
                    ans++;
                }
                auto p5 = calc({x2, y2}, {x1, y1}, {x3, y3});
                if (dist(p1, p2) == dist(p2, p3) && st.count(p5) && p5 != p2) {
                    ans++;
                }
                auto p6 = calc({x3, y3}, {x1, y1}, {x2, y2});
                if (dist(p1, p3) == dist(p2, p3) && st.count(p6) && p6 != p3) {
                    ans++;
                }
            }
        }
    }
    cout << ans / 4 << endl;
}
0