結果

問題 No.2769 Number of Rhombi
ユーザー pop_o
提出日時 2024-06-29 20:53:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 496 ms / 5,000 ms
コード長 794 bytes
コンパイル時間 1,813 ms
コンパイル使用メモリ 179,692 KB
実行使用メモリ 56,832 KB
最終ジャッジ日時 2024-06-29 20:53:45
合計ジャッジ時間 12,302 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:22:27: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   22 |                 for (auto [x, y]: mp[{nx, ny}]) {
      |                           ^

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

map<pair<long long, long long>, vector<pair<long long, long long>>> mp;

int main() {
    int n;
    cin >> n;
    vector<long long> x(n);
    vector<long long> y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            long long tx = x[i]-x[j];
            long long ty = y[i]-y[j];
            long long nx = x[i]+x[j];
            long long ny = y[i]+y[j];
            if (mp.find({nx, ny}) != mp.end()) {
                for (auto [x, y]: mp[{nx, ny}]) {
                    if (tx*x + ty*y == 0) ans++;
                }
            } 
            mp[{nx, ny}].push_back({tx, ty});
        }
    }
    cout << ans << endl;
}
0