結果

問題 No.947 ABC包囲網
ユーザー ngtkanangtkana
提出日時 2020-04-14 20:24:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,646 bytes
コンパイル時間 2,454 ms
コンパイル使用メモリ 205,756 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 18:07:43
合計ジャッジ時間 4,414 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    using pt_t=std::pair<lint,lint>;
    std::vector<pt_t>pt(n);
    for(auto&&p:pt)std::cin>>p.first>>p.second;
    auto det=[&](auto&&p,auto&&q){
        lint a,b;std::tie(a,b)=p;
        lint c,d;std::tie(c,d)=q;
        return a*d-b*c;
    };
    auto inn=[&](auto&&p,auto&&q){
        lint a,b;std::tie(a,b)=p;
        lint c,d;std::tie(c,d)=q;
        return a*b+c*d;
    };
    auto colin=[&det,&inn](auto&&p,auto&&q){return det(p,q)==0&&0<inn(p,q);};
    {
        auto it=std::partition(ALL(pt),[](auto&&p){return 0<p.second||p.second==0&&0<p.first;});
        auto less=[&det](auto&&p,auto&&q){return 0<det(p,q);};
        std::sort(pt.begin(),it,less);
        std::sort(it,pt.end(),less);
    }
    pt.resize(2*n);
    for(lint i=0;i<n;i++)pt.at(i+n)=pt.at(i);
    lint ng=0;
    for(lint l=0,r=0;l<n;l++){
        for(;l==r||r<l+n&&0<=det(pt.at(l),pt.at(r));r++);
        ng+=(r-l-1)*(r-l-2)/2;
    }
    lint doubled=0;
    for(lint l=0,r=0,L=0,R=0;l<n;l=std::max(l+1,r)){
        for(r=l;r==l||colin(pt.at(l),pt.at(r));r++);
        for(L=r;L<l+n&&(0<det(pt.at(l),pt.at(L)));L++);
        for(R=L;R<l+n&&(0<=det(pt.at(l),pt.at(R)));R++);
        lint a=r-l,b=R-L;
        doubled+=a*b*(a+b-2)/2+a*(a-1)*(a-2)/6;
    }
    doubled/=2;
    lint ans=n*(n-1)*(n-2)/6-ng+doubled;
    std::cout<<ans<<'\n';
}
0