結果

問題 No.2355 Unhappy Back Dance
ユーザー t98slidert98slider
提出日時 2023-06-16 23:14:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,534 ms / 6,000 ms
コード長 1,438 bytes
コンパイル時間 1,639 ms
コンパイル使用メモリ 176,152 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 22:10:06
合計ジャッジ時間 21,191 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 137 ms
4,380 KB
testcase_07 AC 114 ms
4,384 KB
testcase_08 AC 134 ms
4,376 KB
testcase_09 AC 134 ms
4,376 KB
testcase_10 AC 261 ms
4,376 KB
testcase_11 AC 278 ms
4,380 KB
testcase_12 AC 149 ms
4,376 KB
testcase_13 AC 150 ms
4,376 KB
testcase_14 AC 284 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1,534 ms
4,380 KB
testcase_17 AC 1,533 ms
4,380 KB
testcase_18 AC 1,533 ms
4,376 KB
testcase_19 AC 1,533 ms
4,376 KB
testcase_20 AC 1,534 ms
4,380 KB
testcase_21 AC 634 ms
4,380 KB
testcase_22 AC 117 ms
4,376 KB
testcase_23 AC 125 ms
4,376 KB
testcase_24 AC 1,379 ms
4,380 KB
testcase_25 AC 741 ms
4,376 KB
testcase_26 AC 743 ms
4,380 KB
testcase_27 AC 634 ms
4,376 KB
testcase_28 AC 14 ms
4,380 KB
testcase_29 AC 34 ms
4,380 KB
testcase_30 AC 1,256 ms
4,376 KB
testcase_31 AC 914 ms
4,376 KB
testcase_32 AC 89 ms
4,380 KB
testcase_33 AC 516 ms
4,376 KB
testcase_34 AC 6 ms
4,380 KB
testcase_35 AC 16 ms
4,376 KB
testcase_36 AC 634 ms
4,380 KB
testcase_37 AC 338 ms
4,380 KB
testcase_38 AC 416 ms
4,380 KB
testcase_39 AC 326 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<ll,ll>> a(n);
    ll x, y, x2, y2;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        a[i] = {x, y};
    }

    vector<bool> used(n);
    for(int i = 0; i < n; i++){
        vector<pair<ll,ll>> b(n);
        for(int j = 0; j < n; j++){
            b[j].first = a[j].first - a[i].first;
            b[j].second = a[j].second - a[i].second;
            ll g = __gcd(b[j].first, b[j].second);
            g = abs(g);
            if(g >= 1){
                b[j].first /= g;
                b[j].second /= g;
            }
        }
        auto c = b;
        sort(c.begin(), c.end());
        for(int j = 0; j < n; j++){
            ll x, y;
            tie(x, y) = b[j];
            if(j == i) continue;
            x *= -1, y *= -1;
            if(binary_search(c.begin(), c.end(), make_pair(x, y))){
                used[j] = true;
            }
        }
    }
    cout << count(used.begin(), used.end(), true) << '\n';
}
0