結果

問題 No.461 三角形はいくつ?
ユーザー Hoi_koroHoi_koro
提出日時 2016-12-14 17:26:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,373 bytes
コンパイル時間 1,452 ms
コンパイル使用メモリ 132,068 KB
実行使用メモリ 253,792 KB
最終ジャッジ日時 2024-05-07 14:11:27
合計ジャッジ時間 33,875 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 695 ms
57,248 KB
testcase_06 AC 383 ms
32,880 KB
testcase_07 AC 472 ms
55,064 KB
testcase_08 AC 323 ms
30,828 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 98 ms
11,348 KB
testcase_11 AC 529 ms
53,840 KB
testcase_12 AC 245 ms
29,284 KB
testcase_13 AC 771 ms
61,864 KB
testcase_14 AC 739 ms
57,828 KB
testcase_15 AC 786 ms
63,904 KB
testcase_16 AC 341 ms
6,944 KB
testcase_17 AC 354 ms
6,940 KB
testcase_18 AC 1,151 ms
114,772 KB
testcase_19 AC 1,188 ms
118,300 KB
testcase_20 WA -
testcase_21 AC 607 ms
58,788 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2,938 ms
253,544 KB
testcase_26 AC 2,761 ms
253,792 KB
testcase_27 AC 5 ms
6,944 KB
testcase_28 AC 4 ms
6,940 KB
testcase_29 AC 2,481 ms
229,636 KB
testcase_30 AC 2,644 ms
242,576 KB
testcase_31 AC 2,220 ms
206,520 KB
testcase_32 AC 2,041 ms
200,156 KB
testcase_33 AC 5 ms
6,940 KB
testcase_34 AC 4 ms
6,944 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 <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
#include <random>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(a) cerr<<(a)<<endl;
#define dump(a) cerr<<#a <<' '<< a <<endl;
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
typedef pair<int,int>PI; typedef vector<int> VI;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;

PLL add(PLL a, PLL b){
    LL g=__gcd(a.SE,b.SE);
    return MP((a.FI*b.SE+a.SE*b.FI)/g,a.SE*b.SE/g);
}
bool comp(PLL a, PLL b){
    return a.FI*b.SE<a.SE*b.FI;
}
bool comp2(pair<PLL,PLL> a, pair<PLL,PLL> b){
    return comp(a.FI,b.FI) or (a.FI==b.FI and comp(a.SE,b.SE));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<PLL>> l(3);
    vector<pair<PLL,PLL>> sum,mi;
    REP(i,n){
        LL a,b,c;
        cin >> a >>b >> c;
        LL g=__gcd(b,c);
        l[a].emplace_back(b/g,(b+c)/g);
    }
    REP(i,3)l[i].emplace_back(1,1);
    REP(i,l[0].size()){
        REP(j,l[1].size()){
            PLL t;
            if(!comp(t=add(l[0][i],l[1][j]),MP(1,1))){
                sum.emplace_back(t,(comp(l[0][i],l[1][j])?l[0][i]:l[1][j]));
                mi.emplace_back((comp(l[0][i],l[1][j])?l[0][i]:l[1][j]),t);
            }
        }
    }
    sort(ALL(sum),comp2);
    sort(ALL(mi),comp2);
    sort(ALL(l[2]),comp);
    LL ans=sum.size()*l[2].size();

    REP(i,l[2].size()){
        LL num=l[2][i].FI,den=l[2][i].SE;
        LL point=upper_bound(ALL(sum),MP(MP(2*den-num,den),MP(INF,1)),comp2)-lower_bound(ALL(sum),MP(MP(2*den-num,den),MP(0,1)),comp2);
        LL outside=lower_bound(ALL(mi),MP(MP(den-num,den),MP(0,1)),comp2)-mi.begin();
        ans-=point+outside;
    }
    cout << ans <<endl;




    return 0;
}
0