結果

問題 No.2355 Unhappy Back Dance
ユーザー momoyuu
提出日時 2023-07-12 15:19:27
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,664 ms / 6,000 ms
コード長 975 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 144,760 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-14 05:02:51
合計ジャッジ時間 22,287 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
#include<cassert>
#include<cmath>
#include<iomanip>
#include<map>
#include<functional>
//#include<bits/stdc++.h>
using namespace std;
using ll = long long;

ll gcd(ll a,ll b){
    if(b) return gcd(b,a%b);
    return a;
}

int main(){
    int cnt = 0;
    int n;
    cin>>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++){
        map<pair<ll,ll>,int> d;
        bool ok = false;
        for(int j = 0;j<n;j++){
            if(i==j) continue;
            ll dx = x[j] - x[i];
            ll dy = y[j] - y[i];
            if(dx==0) dy/=abs(dy);
            else if(dx==0) dx /= abs(dx);
            else{
                ll g = gcd(abs(dx),abs(dy));
                dx /= g;
                dy /= g;
            }
            if(d[make_pair(dx,dy)]++) ok = true;
        }
        if(ok) cnt++;
    }
    cout<<cnt<<endl;
}
0