結果

問題 No.461 三角形はいくつ?
ユーザー titiatitia
提出日時 2023-09-19 03:56:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,295 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 79,776 KB
最終ジャッジ日時 2023-09-19 03:57:26
合計ジャッジ時間 27,287 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
72,588 KB
testcase_01 AC 114 ms
72,460 KB
testcase_02 AC 138 ms
72,552 KB
testcase_03 AC 111 ms
72,740 KB
testcase_04 AC 128 ms
77,612 KB
testcase_05 AC 596 ms
78,808 KB
testcase_06 AC 445 ms
78,612 KB
testcase_07 AC 437 ms
78,780 KB
testcase_08 AC 348 ms
78,992 KB
testcase_09 AC 152 ms
77,632 KB
testcase_10 AC 213 ms
78,620 KB
testcase_11 AC 471 ms
78,708 KB
testcase_12 AC 296 ms
79,060 KB
testcase_13 AC 657 ms
79,328 KB
testcase_14 AC 606 ms
79,452 KB
testcase_15 AC 640 ms
79,204 KB
testcase_16 AC 166 ms
78,904 KB
testcase_17 AC 161 ms
78,888 KB
testcase_18 AC 957 ms
79,012 KB
testcase_19 AC 975 ms
78,800 KB
testcase_20 WA -
testcase_21 AC 647 ms
79,776 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1,592 ms
79,152 KB
testcase_26 AC 1,583 ms
79,076 KB
testcase_27 AC 162 ms
78,916 KB
testcase_28 AC 158 ms
78,584 KB
testcase_29 AC 1,751 ms
78,896 KB
testcase_30 AC 1,776 ms
78,828 KB
testcase_31 AC 1,572 ms
78,860 KB
testcase_32 AC 1,495 ms
78,908 KB
testcase_33 AC 146 ms
78,600 KB
testcase_34 AC 143 ms
78,660 KB
testcase_35 AC 146 ms
78,600 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 #

import sys
input = sys.stdin.readline

from bisect import bisect_left
from collections import Counter
from math import gcd

L=[[(0,1)] for i in range(3)]

N=int(input())

for i in range(N):
    p,a,b=map(int,input().split())
    G=gcd(a,b)
    L[p].append((b//G,(a+b)//G))

from functools import cmp_to_key

def cmp(a, b):
    if a[0]*b[1]>b[0]*a[1]:
        return 1
    elif a[0]*b[1]==b[0]*a[1]:
        return 0
    else:
        return -1

L[0].sort(key=cmp_to_key(cmp))
L[1].sort(key=cmp_to_key(cmp))
L[2].sort(key=cmp_to_key(cmp))

ANS=0
C=Counter(L[2])

for x0,x1 in L[0]:
    for y0,y1 in L[1]:
        if x0*y1+x1*y0>x1*y1:
            break

        if x0*y1>x1*y0:
            MAX=(x0,x1)
        else:
            MAX=(y0,y1)

        m0,m1=MAX

        OK=-1
        NG=len(L[2])

        while NG>OK+1:
            mid=(OK+NG)//2

            z0,z1=L[2][mid]

            if z0*m1<(m1-m0)*z1:
                OK=mid
            else:
                NG=mid

        #print(x0,x1,y0,y1,L[2],OK)

        ANS+=OK+1
        z0=x1*y1-(x0*y1+x1*y0)
        z1=x1*y1
        G=gcd(z0,z1)
        z0//=G
        z1//=G
        
        if z0*m1<(m1-m0)*z1 and (z1-z0,z1) in C:
            ANS-=C[(z0,z1)]

            #print("!",x0,x1,y0,y1,MAX,z0,z1,C[(z0,z1)])

print(ANS)


        

0