結果
問題 | No.457 (^^*) |
ユーザー | 👑 Kazun |
提出日時 | 2021-02-07 19:27:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 121 ms / 2,000 ms |
コード長 | 1,950 bytes |
コンパイル時間 | 1,768 ms |
コンパイル使用メモリ | 87,036 KB |
実行使用メモリ | 78,444 KB |
最終ジャッジ日時 | 2023-09-17 17:50:58 |
合計ジャッジ時間 | 3,013 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 67 ms
71,580 KB |
testcase_01 | AC | 68 ms
71,392 KB |
testcase_02 | AC | 69 ms
71,532 KB |
testcase_03 | AC | 68 ms
71,092 KB |
testcase_04 | AC | 68 ms
71,528 KB |
testcase_05 | AC | 68 ms
71,536 KB |
testcase_06 | AC | 69 ms
71,248 KB |
testcase_07 | AC | 79 ms
75,736 KB |
testcase_08 | AC | 82 ms
75,844 KB |
testcase_09 | AC | 90 ms
76,460 KB |
testcase_10 | AC | 106 ms
77,264 KB |
testcase_11 | AC | 121 ms
78,444 KB |
testcase_12 | AC | 104 ms
77,360 KB |
testcase_13 | AC | 104 ms
77,456 KB |
testcase_14 | AC | 73 ms
76,196 KB |
testcase_15 | AC | 108 ms
77,320 KB |
testcase_16 | AC | 107 ms
77,252 KB |
testcase_17 | AC | 72 ms
75,992 KB |
testcase_18 | AC | 67 ms
71,572 KB |
testcase_19 | AC | 66 ms
71,564 KB |
ソースコード
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 0 L,R=-1,len(A)-1 while R-L>1: C=L+(R-L)//2 if A[C]>x or (equal and A[C]==x): R=C else: L=C return len(A)-R def 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 None L,R=-1,len(A)-1 while R-L>1: C=L+(R-L)//2 if A[C]>x or (equal and A[C]==x): R=C else: L=C K=len(A)-R return 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=0 for a in A: p=a p=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=0 for a in A: q=a q=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)