結果

問題 No.2355 Unhappy Back Dance
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-16 23:25:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2,669 ms / 6,000 ms
コード長 1,159 bytes
コンパイル時間 1,048 ms
コンパイル使用メモリ 116,708 KB
最終ジャッジ日時 2025-02-14 21:37:42
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    ll N, ans=0, dx, dy;
    cin >> N;
    vector<map<pair<ll, ll>, ll>> v(N);
    vector<ll> x(N), y(N);
    for (int i=0; i<N; i++) cin >> x[i] >> y[i];
    for (int i=0; i<N; i++){
        for (int j=i+1; j<N; j++){
            dx = x[i]-x[j];
            dy = y[i]-y[j];
            ll g = gcd(dx, dy);
            if (g == 0){
                if (dx == 0){
                    dx = 0;
                    dy /= abs(dy);
                }
                else{
                    dx /= abs(dx);
                    dy = 0;
                }
            }
            else{
                dx /= g;
                dy /= g;
            }
            v[i][{dx, dy}]++;
            v[j][{-dx, -dy}]++;
        }
    }

    for (int i=0; i<N; i++){
        bool f=0;
        for (auto [x, y] : v[i]) if (y >= 2) f=1;
        ans += f;
    }

    cout << ans << endl;

    return 0;
}
0