結果

問題 No.2769 Number of Rhombi
ユーザー Today03Today03
提出日時 2024-05-31 22:34:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,264 bytes
コンパイル時間 2,910 ms
コンパイル使用メモリ 227,116 KB
実行使用メモリ 112,768 KB
最終ジャッジ日時 2024-05-31 22:35:53
合計ジャッジ時間 51,380 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2,584 ms
48,256 KB
testcase_04 AC 3,015 ms
34,688 KB
testcase_05 AC 2,113 ms
24,576 KB
testcase_06 AC 2,932 ms
30,080 KB
testcase_07 AC 3,744 ms
36,224 KB
testcase_08 AC 3,404 ms
38,784 KB
testcase_09 AC 2,776 ms
43,648 KB
testcase_10 AC 2,089 ms
52,352 KB
testcase_11 AC 1,797 ms
61,696 KB
testcase_12 AC 1,628 ms
72,320 KB
testcase_13 AC 1,681 ms
82,688 KB
testcase_14 AC 2,024 ms
95,360 KB
testcase_15 AC 2,220 ms
98,688 KB
testcase_16 AC 2,481 ms
102,528 KB
testcase_17 AC 2,832 ms
105,984 KB
testcase_18 AC 4,227 ms
111,360 KB
testcase_19 AC 4,757 ms
112,768 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9 + 10;
const ll INFL = 4e18;

int main() {
    int N;
    cin >> N;
    vector<pair<ll, ll>> XY(N);
    for (int i = 0; i < N; i++) {
        cin >> XY[i].first >> XY[i].second;
    }

    map<ll, map<int, vector<int>>> mp;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            ll dx = XY[j].first - XY[i].first;
            ll dy = XY[j].second - XY[i].second;
            ll d = dx * dx + dy * dy;
            mp[d][i].push_back(j);
            mp[d][j].push_back(i);
        }
    }

    ll ans = 0;
    for (auto [k, G] : mp) {
        for (int i = 0; i < N; i++) {
            if (G[i].size() < 2) continue;
            queue<tuple<int, int, int>> Q;
            Q.push({i, 0, -1});
            while (!Q.empty()) {
                auto [now, c, pre] = Q.front();
                Q.pop();
                for (auto nxt : G[now]) {
                    if (nxt == pre) continue;
                    if (c == 3) {
                        if (nxt == i) ans++;
                        continue;
                    }
                    Q.push({nxt, c + 1, now});
                }
            }
        }
    }

    cout << ans / 8 << endl;
}
0