結果

問題 No.2355 Unhappy Back Dance
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-16 23:19:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,384 bytes
コンパイル時間 1,090 ms
コンパイル使用メモリ 119,012 KB
実行使用メモリ 144,260 KB
最終ジャッジ日時 2023-09-06 22:22:03
合計ジャッジ時間 30,916 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 59 ms
4,376 KB
testcase_07 AC 60 ms
4,380 KB
testcase_08 AC 68 ms
4,380 KB
testcase_09 AC 71 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 69 ms
4,376 KB
testcase_13 AC 68 ms
4,376 KB
testcase_14 AC 630 ms
73,848 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2,656 ms
143,992 KB
testcase_17 AC 2,660 ms
144,260 KB
testcase_18 AC 2,669 ms
144,100 KB
testcase_19 AC 2,661 ms
143,952 KB
testcase_20 AC 2,646 ms
144,252 KB
testcase_21 AC 827 ms
62,244 KB
testcase_22 AC 113 ms
14,232 KB
testcase_23 AC 116 ms
14,972 KB
testcase_24 AC 2,244 ms
130,272 KB
testcase_25 AC 1,148 ms
71,736 KB
testcase_26 AC 1,142 ms
72,004 KB
testcase_27 AC 854 ms
63,088 KB
testcase_28 AC 12 ms
4,632 KB
testcase_29 AC 28 ms
6,528 KB
testcase_30 AC 2,026 ms
120,844 KB
testcase_31 AC 1,440 ms
89,172 KB
testcase_32 AC 79 ms
11,800 KB
testcase_33 AC 676 ms
51,928 KB
testcase_34 AC 5 ms
4,380 KB
testcase_35 AC 13 ms
4,712 KB
testcase_36 AC 851 ms
63,268 KB
testcase_37 AC 395 ms
35,276 KB
testcase_38 AC 518 ms
42,684 KB
testcase_39 AC 377 ms
34,376 KB
権限があれば一括ダウンロードができます

ソースコード

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