結果

問題 No.461 三角形はいくつ?
ユーザー parukiparuki
提出日時 2016-12-13 15:51:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,827 bytes
コンパイル時間 1,713 ms
コンパイル使用メモリ 180,628 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-07 09:29:26
合計ジャッジ時間 6,113 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 13 ms
6,940 KB
testcase_17 AC 13 ms
6,940 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 8 ms
6,948 KB
testcase_26 AC 8 ms
6,944 KB
testcase_27 AC 8 ms
6,944 KB
testcase_28 AC 8 ms
6,944 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 3 ms
6,940 KB
testcase_34 AC 3 ms
6,940 KB
testcase_35 AC 4 ms
6,944 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;

bool les(pll x, pll y) {
    return x.first*y.second < y.first*x.second;
}

bool f(pll x, pll y) {
    return x.first*y.second + x.second*y.first <= x.second*y.second;
}

bool g(pll x, pll y) {
    return x.first*y.second + x.second*y.first < x.second*y.second;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vi p(N), a(N), b(N);
    rep(i, N)cin >> p[i] >> a[i] >> b[i];

    vector<vector<pll>> vv(3);
    rep(i, N) {
        vv[p[i]].push_back(mp(b[i], a[i] + b[i]));
    }
    rep(i, 3)sort(all(vv[i]), les);

    ll ans = N + 1;
    if(sz(vv[0])*sz(vv[1])*sz(vv[2])) each(s, vv[0]) {
        each(t, vv[1]) if(f(s, t) && f(s,vv[2][0]) && f(t, vv[2][0])){
            int lb = 0, ub = sz(vv[2]), m;
            while(ub - lb > 1) {
                m = (lb + ub) >> 1;
                ((f(s, vv[2][m]) && f(t, vv[2][m])) ? lb : ub) = m;
            }
            ll d = s.second*t.second;
            pll ng(d - s.first*t.second - t.first*s.second, d);
            ans += ub - lb;
            if(binary_search(all(vv[2]), ng, les)) {
                --ans;
            }
        }
    }

    rep(i, 3) {
        int j = (i + 1) % 3;
        each(s, vv[i])each(t, vv[j])if(g(s, t))ans++;
    }

    cout << ans << endl;
}
0