結果

問題 No.461 三角形はいくつ?
ユーザー titiatitia
提出日時 2023-09-19 03:50:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,133 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 79,156 KB
最終ジャッジ日時 2023-09-19 03:51:05
合計ジャッジ時間 26,300 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,692 KB
testcase_01 AC 94 ms
71,428 KB
testcase_02 AC 109 ms
71,848 KB
testcase_03 AC 92 ms
71,964 KB
testcase_04 AC 111 ms
77,132 KB
testcase_05 AC 562 ms
78,476 KB
testcase_06 AC 373 ms
78,380 KB
testcase_07 AC 403 ms
78,440 KB
testcase_08 AC 322 ms
78,444 KB
testcase_09 AC 111 ms
77,488 KB
testcase_10 AC 187 ms
78,448 KB
testcase_11 AC 476 ms
78,576 KB
testcase_12 AC 271 ms
78,564 KB
testcase_13 AC 639 ms
78,356 KB
testcase_14 AC 578 ms
78,708 KB
testcase_15 AC 628 ms
78,420 KB
testcase_16 AC 128 ms
78,172 KB
testcase_17 AC 128 ms
77,924 KB
testcase_18 AC 923 ms
78,432 KB
testcase_19 AC 904 ms
78,348 KB
testcase_20 WA -
testcase_21 AC 596 ms
78,692 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1,571 ms
78,264 KB
testcase_26 AC 1,544 ms
78,324 KB
testcase_27 AC 118 ms
77,840 KB
testcase_28 AC 117 ms
78,208 KB
testcase_29 AC 1,644 ms
78,320 KB
testcase_30 AC 1,739 ms
78,232 KB
testcase_31 AC 1,528 ms
78,364 KB
testcase_32 AC 1,461 ms
78,356 KB
testcase_33 AC 118 ms
78,180 KB
testcase_34 AC 131 ms
77,892 KB
testcase_35 AC 112 ms
77,728 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))

L[0].sort(key=lambda x:x[0]/x[1])
L[1].sort(key=lambda x:x[0]/x[1])
L[2].sort(key=lambda x:x[0]/x[1])

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