結果
問題 |
No.2769 Number of Rhombi
|
ユーザー |
|
提出日時 | 2024-05-31 22:33:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,089 bytes |
コンパイル時間 | 2,383 ms |
コンパイル使用メモリ | 206,404 KB |
最終ジャッジ日時 | 2025-02-21 18:09:31 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pair<ll,ll>> a(n); for(auto &&[x, y] : a){ cin >> x >> y; x *= 2, y *= 2; } vector<tuple<ll,ll,ll,ll>> b, c; for(int i = 0; i < n; i++){ auto &&[x1, y1] = a[i]; for(int j = i + 1; j < n; j++){ auto &&[x2, y2] = a[j]; ll dx = x2 - x1; ll dy = y2 - y1; ll g = gcd(abs(dx), abs(dy)); dx /= g, dy /= g; if(dx < 0) dx *= -1, dy *= -1; b.emplace_back((x1 + x2) / 2, (y1 + y2) / 2, dx, dy); if(dx != 0 && dy != 0) dy *= -1; swap(dx, dy); if(dx < 0) dx *= -1, dy *= -1; c.emplace_back((x1 + x2) / 2, (y1 + y2) / 2, dx, dy); } } sort(c.begin(), c.end()); ll ans = 0; for(auto &&tup : b){ ans += upper_bound(c.begin(), c.end(), tup) - lower_bound(c.begin(), c.end(), tup); } cout << ans / 2 << '\n'; }