結果

問題 No.2355 Unhappy Back Dance
ユーザー milanis48663220milanis48663220
提出日時 2023-06-16 22:26:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,014 bytes
コンパイル時間 1,286 ms
コンパイル使用メモリ 125,616 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-06 20:38:28
合計ジャッジ時間 6,476 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 11 ms
4,380 KB
testcase_07 AC 11 ms
4,380 KB
testcase_08 AC 11 ms
4,380 KB
testcase_09 RE -
testcase_10 AC 127 ms
4,380 KB
testcase_11 AC 126 ms
4,380 KB
testcase_12 AC 11 ms
4,380 KB
testcase_13 AC 10 ms
4,376 KB
testcase_14 AC 139 ms
4,384 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

using P = pair<int, int>;

bool ok(vector<int> x, vector<int> y){
    int n = x.size();
    set<P> st;
    for(int i = 0; i < n; i++){
        int a = x[i], b = y[i];
        int g = gcd(a, b);
        if(g < 0) g *= -1;
        a /= g;
        b /= g;
        if(st.count({a, b})) return true;
        st.insert({a, b});
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    vector<int> x(n), y(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        vector<int> u, v;
        for(int j = 0; j < n; j++){
            if(i == j) continue;
            u.push_back(x[j]-x[i]);
            v.push_back(y[j]-y[i]);
        }
        if(ok(u, v)) ans++;
    }
    cout << ans << endl;
}
0