結果
問題 | No.457 (^^*) |
ユーザー |
👑 ![]() |
提出日時 | 2021-02-07 19:27:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 96 ms / 2,000 ms |
コード長 | 1,950 bytes |
コンパイル時間 | 407 ms |
コンパイル使用メモリ | 82,452 KB |
実行使用メモリ | 76,604 KB |
最終ジャッジ日時 | 2024-07-04 12:25:49 |
合計ジャッジ時間 | 2,119 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
def Binary_Search_Big_Count(A,x,equal=False,sort=False):"""2分探索によって,xを超える要素の個数を調べる.A:リストx:調べる要素sort:ソートをする必要があるかどうか(Trueで必要)equal:Trueのときはx"を超える"がx"以上"になる"""if sort:A.sort()if A[-1]<x or ((not equal) and A[-1]==x):return 0L,R=-1,len(A)-1while R-L>1:C=L+(R-L)//2if A[C]>x or (equal and A[C]==x):R=Celse:L=Creturn len(A)-Rdef Binary_Search_High_Value(A,x,equal=False,sort=False):"""Aのxを超える要素の中で最小のものを出力する.A:リストx:調べる要素sort:ソートをする必要があるかどうか(Trueで必要)equal:Trueのときはx"を超える"がx"以上"になる※全ての要素がx以上(超える)場合はNoneが返される."""if sort:A.sort()if A[-1]<x or ((not equal) and A[-1]==x):return NoneL,R=-1,len(A)-1while R-L>1:C=L+(R-L)//2if A[C]>x or (equal and A[C]==x):R=Celse:L=CK=len(A)-Rreturn A[-K]#================================================S=input()A=[]B=[-1]C=[-1]D=[-1]for i,s in enumerate(S):if s=="(":A.append(i)elif s=="^":B.append(i)elif s=="*":C.append(i)else:D.append(i)X=0for a in A:p=ap=Binary_Search_High_Value(B,p)if p!=None:p=Binary_Search_High_Value(B,p)if p!=None:p=Binary_Search_High_Value(C,p)if p!=None:X+=Binary_Search_Big_Count(D,p)Y=0for a in A:q=aq=Binary_Search_High_Value(C,q)if q!=None:q=Binary_Search_High_Value(B,q)if q!=None:q=Binary_Search_High_Value(B,q)if q!=None:Y+=Binary_Search_Big_Count(D,q)print(X,Y)