結果
| 問題 |
No.2769 Number of Rhombi
|
| コンテスト | |
| ユーザー |
Today03
|
| 提出日時 | 2024-05-31 22:34:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,264 bytes |
| コンパイル時間 | 2,577 ms |
| コンパイル使用メモリ | 217,092 KB |
| 最終ジャッジ日時 | 2025-02-21 18:11:14 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 TLE * 2 -- * 13 |
ソースコード
#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;
}
Today03