結果

問題 No.2355 Unhappy Back Dance
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-16 23:25:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,363 ms / 6,000 ms
コード長 1,159 bytes
コンパイル時間 2,159 ms
コンパイル使用メモリ 118,600 KB
実行使用メモリ 144,032 KB
最終ジャッジ日時 2023-09-06 22:29:58
合計ジャッジ時間 29,702 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 41 ms
4,376 KB
testcase_07 AC 40 ms
4,376 KB
testcase_08 AC 41 ms
4,376 KB
testcase_09 AC 41 ms
4,380 KB
testcase_10 AC 1,019 ms
73,916 KB
testcase_11 AC 912 ms
73,940 KB
testcase_12 AC 43 ms
4,384 KB
testcase_13 AC 44 ms
4,380 KB
testcase_14 AC 834 ms
73,996 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2,355 ms
143,984 KB
testcase_17 AC 2,363 ms
143,968 KB
testcase_18 AC 2,329 ms
143,968 KB
testcase_19 AC 2,329 ms
144,032 KB
testcase_20 AC 2,333 ms
143,968 KB
testcase_21 AC 689 ms
62,092 KB
testcase_22 AC 82 ms
14,208 KB
testcase_23 AC 86 ms
14,976 KB
testcase_24 AC 1,919 ms
130,308 KB
testcase_25 AC 955 ms
71,740 KB
testcase_26 AC 991 ms
71,996 KB
testcase_27 AC 748 ms
63,176 KB
testcase_28 AC 8 ms
4,648 KB
testcase_29 AC 21 ms
6,504 KB
testcase_30 AC 1,746 ms
120,900 KB
testcase_31 AC 1,252 ms
89,108 KB
testcase_32 AC 61 ms
11,776 KB
testcase_33 AC 579 ms
51,972 KB
testcase_34 AC 4 ms
4,384 KB
testcase_35 AC 10 ms
4,748 KB
testcase_36 AC 758 ms
63,176 KB
testcase_37 AC 322 ms
35,200 KB
testcase_38 AC 433 ms
42,544 KB
testcase_39 AC 333 ms
34,160 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;

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