結果

問題 No.461 三角形はいくつ?
ユーザー chocoruskchocorusk
提出日時 2019-12-07 18:35:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 5,000 ms
コード長 1,760 bytes
コンパイル時間 1,068 ms
コンパイル使用メモリ 115,752 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 22:56:07
合計ジャッジ時間 4,500 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 84 ms
4,380 KB
testcase_06 AC 48 ms
4,376 KB
testcase_07 AC 56 ms
4,376 KB
testcase_08 AC 37 ms
4,384 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 13 ms
4,380 KB
testcase_11 AC 64 ms
4,380 KB
testcase_12 AC 28 ms
4,376 KB
testcase_13 AC 92 ms
4,376 KB
testcase_14 AC 86 ms
4,376 KB
testcase_15 AC 93 ms
4,376 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 8 ms
4,376 KB
testcase_18 AC 64 ms
4,380 KB
testcase_19 AC 66 ms
4,380 KB
testcase_20 AC 94 ms
4,376 KB
testcase_21 AC 89 ms
4,380 KB
testcase_22 AC 88 ms
4,376 KB
testcase_23 AC 14 ms
4,376 KB
testcase_24 AC 13 ms
4,380 KB
testcase_25 AC 56 ms
4,380 KB
testcase_26 AC 55 ms
4,376 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 5 ms
4,380 KB
testcase_29 AC 102 ms
4,376 KB
testcase_30 AC 100 ms
4,380 KB
testcase_31 AC 100 ms
4,380 KB
testcase_32 AC 98 ms
4,376 KB
testcase_33 AC 4 ms
4,380 KB
testcase_34 AC 5 ms
4,376 KB
testcase_35 AC 4 ms
4,380 KB
testcase_36 AC 23 ms
4,376 KB
testcase_37 AC 20 ms
4,380 KB
testcase_38 AC 21 ms
4,380 KB
testcase_39 AC 19 ms
4,376 KB
testcase_40 AC 21 ms
4,376 KB
testcase_41 AC 22 ms
4,376 KB
testcase_42 AC 73 ms
4,380 KB
testcase_43 AC 72 ms
4,376 KB
testcase_44 AC 76 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
struct R{
  ll x, y;
  R(ll x, ll y):x(x), y(y){}
  R(ll x):x(x), y(1ll){}
  R operator+(const R a) const{
    return R(x*a.y+y*a.x, y*a.y);
  }
  R operator-(const R a) const{
    return R(x*a.y-y*a.x, y*a.y);
  }
  bool operator==(const R a) const{
    return x*a.y==y*a.x;
  }
  bool operator<(const R a) const{
    return x*a.y<y*a.x;
  }
  bool operator>=(const R a) const{
    return x*a.y>=y*a.x;
  }
};
int main()
{
    int n;
    cin>>n;
    vector<R> v[3];
    for(int i=0; i<n; i++){
        int p; ll a, b;
        cin>>p>>a>>b;
        v[p].push_back(R(a, a+b));
    }
    for(int i=0; i<3; i++){
        v[i].push_back(R(1));
        sort(v[i].begin(), v[i].end());
    }
    ll ans=0;
    for(int i=0; i<v[0].size(); i++){
        for(int j=0; j<v[1].size(); j++){
            R x=v[0][i], y=v[1][j];
            if(x+y<R(1)) continue;
            R z=max(R(1)-x, R(1)-y);
            int k=lower_bound(v[2].begin(), v[2].end(), z)-v[2].begin();
            ans+=(int)v[2].size()-k;
            k=lower_bound(v[2].begin(), v[2].end(), R(2)-x-y)-v[2].begin();
            if(k<v[2].size() && v[2][k]==R(2)-x-y && x+v[2][k]>=R(1) && y+v[2][k]>=R(1)) ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}
0