結果

問題 No.947 ABC包囲網
ユーザー face4face4
提出日時 2019-12-10 22:11:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,744 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 86,776 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 07:40:52
合計ジャッジ時間 8,535 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 156 ms
4,376 KB
testcase_17 WA -
testcase_18 AC 245 ms
4,376 KB
testcase_19 AC 237 ms
4,380 KB
testcase_20 AC 246 ms
4,376 KB
testcase_21 AC 248 ms
4,384 KB
testcase_22 AC 242 ms
4,380 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// ?
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;

#define EPS 0.00000001
#define equals(a, b) (fabs(a-b) < EPS)

const long double PI = 2*acos(0);

long double arg(long double x, long double y){
    return (atan2(y, x)>0 ? atan2(y,x) : 2*PI+atan2(y,x)) / PI * 180.0;
}

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<long double> v, x(n), y(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        v.push_back(arg(x[i], y[i]));
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(equals(v[i],v[j]) || equals(fabs(v[i]-v[j]),180))    continue;
            long double f = v[i]+180, g = v[j]+180;
            if(f < 360 && g < 360){
                ans += lower_bound(v.begin(),v.end(),g)-upper_bound(v.begin(),v.end(),f);
            }else if(f < 360 && g >= 360){
                long double diff = min(v[j]-v[i], 360-(v[j]-v[i]));
                g -= 360;
                if(equals(g+360-f, diff)){
                    ans += v.end() - upper_bound(v.begin(),v.end(),f);
                    ans += lower_bound(v.begin(),v.end(),g) - v.begin();
                }else{
                    swap(f, g);
                    ans += lower_bound(v.begin(),v.end(),g)-upper_bound(v.begin(),v.end(),f);
                }
            }else if(f >= 360 && g >= 360){
                f -= 360;
                g -= 360;
                ans += lower_bound(v.begin(),v.end(),g)-upper_bound(v.begin(),v.end(),f);
            }
            cerr << i << " " << j << " " << ans << endl;
        }
    }
    cerr << ans << endl;
    cout << ans/3 << endl;
    return 0;
}
0