結果

問題 No.2769 Number of Rhombi
ユーザー Today03Today03
提出日時 2024-05-31 22:33:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,344 bytes
コンパイル時間 2,898 ms
コンパイル使用メモリ 223,988 KB
実行使用メモリ 814,464 KB
最終ジャッジ日時 2024-05-31 22:33:44
合計ジャッジ時間 23,956 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 828 ms
35,328 KB
testcase_04 AC 1,037 ms
26,112 KB
testcase_05 AC 829 ms
19,072 KB
testcase_06 AC 1,146 ms
23,296 KB
testcase_07 AC 1,409 ms
27,776 KB
testcase_08 AC 1,328 ms
29,440 KB
testcase_09 AC 1,082 ms
32,256 KB
testcase_10 AC 772 ms
38,656 KB
testcase_11 AC 660 ms
47,360 KB
testcase_12 AC 587 ms
61,312 KB
testcase_13 AC 607 ms
83,456 KB
testcase_14 AC 752 ms
138,624 KB
testcase_15 AC 805 ms
177,152 KB
testcase_16 AC 947 ms
229,248 KB
testcase_17 AC 1,126 ms
316,416 KB
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 -- -
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, vector<vector<ll>>> 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;
            if (mp.count(d) == 0) {
                mp[d].resize(N);
            }
            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