結果

問題 No.947 ABC包囲網
ユーザー roarisroaris
提出日時 2019-12-10 23:15:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,446 bytes
コンパイル時間 1,867 ms
コンパイル使用メモリ 172,468 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-06 07:50:03
合計ジャッジ時間 6,411 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,652 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 16 ms
4,380 KB
testcase_19 AC 16 ms
4,380 KB
testcase_20 AC 17 ms
4,376 KB
testcase_21 AC 17 ms
4,380 KB
testcase_22 AC 17 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 <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;

signed main() {
    int n; cin >> n;
    vector<P> xy;
    
    for (int i=0; i<n; i++) {
        int xi, yi; cin >> xi >> yi;
        xy.push_back(P(xi, yi));
    }
    
    sort(xy.begin(), xy.end(), [](auto const& lhs, auto const& rhs){return lhs.first<rhs.first;});
    int ans = 0;
    
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            for (int k=j+1; k<n; k++) {
                int x1=xy[i].first, y1=xy[i].second;
                int x2=xy[j].first, y2=xy[j].second;
                int x3=xy[k].first, y3=xy[k].second;
                
                if (x1==x2 && x2==x3) {
                    continue;
                }
                else if (x1==x2) {
                    if ((x1*y3-y1*x3>0 && x2*y3-y2*x3<0) || (x1*y3-y1*x3<0 && x2*y3-y2*x3>0)) {
                        ans++;
                    }
                }
                else if (x2==x3) {
                    if ((x2*y1-y2*x1>0 && x3*y1-y3*x1<0) || (x2*y1-y2*x1<0 && x3*y1-y3*x1>0)) {
                        ans++;
                    }
                }
                else {
                    if ((x1*y2-y1*x2<0 && x2*y3-y2*x3<0 && x1*y3-y1*x3>0) || (x1*y2-y1*x2>0 && x2*y3-y2*x3>0 && x1*y3-y1*x3<0)) {
                        ans++;
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
}
0