結果

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

ソースコード

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;

struct fraction{
    long long p, q;
    fraction(long long P=0, long long Q=1) : p(P), q(Q) {
        if (Q < 0){
            p *= -1;
            q *= -1;
        }
        long long g=gcd(abs(p), abs(q));
        p /= g;
        q /= g;
    }
    bool operator < (const fraction & other) const{
        if (p < 0) return -p*other.q > -other.p*q;
        return p*other.q < other.p*q;
    }
    bool operator == (const fraction & other) const{
        return (p == other.p) && (q == other.q);
    }
    bool operator > (const fraction & other) const{
        if (p < 0) return -p*other.q < -other.p*q;
        return p*other.q > other.p*q;
    }
};

int main(){

    ll N, ans=0;
    cin >> N;
    vector<map<fraction, 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++){
            v[i][fraction(x[i]-x[j], y[i]-y[j])]++;
            v[j][fraction(x[j]-x[i], y[j]-y[i])]++;
        }
    }

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

    cout << ans << endl;

    return 0;
}
0