結果

問題 No.947 ABC包囲網
ユーザー tko919tko919
提出日時 2019-12-13 22:07:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,157 bytes
コンパイル時間 1,735 ms
コンパイル使用メモリ 174,364 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-27 15:56:16
合計ジャッジ時間 3,833 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end



int main(){
    int n; scanf("%d",&n);
    vector<double> a;
    rep(i,0,n){
        int x,y; scanf("%d%d",&x,&y);
        if(x==0&&y==0)continue;
        double theta=atan2(x,y);
        cerr<<theta<<endl;
        a.push_back(theta); 
        a.push_back(theta+2*M_PI);
        a.push_back(theta+4*M_PI);
    }
    sort(ALL(a)); n=a.size()/3;
    ll ans=0; int idx=0;
    rep(i,0,n){
        chmax(idx,i);
        while(a[idx]-a[i]<M_PI-1e-12){
            int add=lower_bound(ALL(a),a[idx]+M_PI)-lower_bound(ALL(a),a[i]+M_PI);
            if(binary_search(ALL(a),a[idx]+M_PI)&&add)add--;
            ans+=add; idx++;
        }
    }
    printf("%lld\n",ans/3);
    return 0;
}
0