結果

問題 No.2455 Numbers Dictionary
ユーザー ゼットゼット
提出日時 2023-09-01 23:04:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,568 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 619 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 82,852 KB
最終ジャッジ日時 2023-09-01 23:05:24
合計ジャッジ時間 26,932 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
76,732 KB
testcase_01 AC 71 ms
71,372 KB
testcase_02 AC 1,118 ms
79,916 KB
testcase_03 AC 1,200 ms
79,836 KB
testcase_04 AC 1,225 ms
80,184 KB
testcase_05 AC 1,112 ms
79,644 KB
testcase_06 AC 1,454 ms
80,064 KB
testcase_07 AC 1,421 ms
82,852 KB
testcase_08 AC 610 ms
80,300 KB
testcase_09 AC 1,429 ms
81,568 KB
testcase_10 AC 1,568 ms
80,372 KB
testcase_11 AC 1,526 ms
81,012 KB
testcase_12 AC 918 ms
80,524 KB
testcase_13 AC 1,463 ms
80,344 KB
testcase_14 AC 1,263 ms
80,276 KB
testcase_15 AC 1,483 ms
79,920 KB
testcase_16 AC 496 ms
80,076 KB
testcase_17 AC 1,374 ms
80,056 KB
testcase_18 AC 250 ms
78,344 KB
testcase_19 AC 310 ms
79,356 KB
testcase_20 AC 1,477 ms
80,428 KB
testcase_21 AC 1,475 ms
80,480 KB
testcase_22 AC 1,312 ms
80,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Q=int(input())
for _ in range(Q):
  S,T=input().split()
  N=len(S)
  M=len(T)
  result=0
  u=[[0]*2 for i in range(N+1)]
  w=''
  for i in range(N):
    u2=[[0]*2 for i in range(N+1)]
    for j in range(1,N):
      for x in range(10):  
        if j>=M:
          u2[j+1][0]+=u[j][0]  
        else:
          y=int(T[j])  
          if x<y:
            u2[j+1][0]+=u[j][0]+u[j][1]
          elif x==y:
            u2[j+1][0]+=u[j][0]  
            u2[j+1][1]+=u[j][1]
          else:
            u2[j+1][0]+=u[j][0]
    y=int(S[i])
    if i>0:
      for x in range(1,10):
        if x<int(T[0]):
          u2[1][0]+=1
        elif x==int(T[0]):
          u2[1][1]+=1
      for x in range(y):
        s=w+str(x)
        if i>=M:  
          t=T
        else:
          t=T[:i+1]
        if s==t:
          u2[i+1][1]+=1  
        else:
          L=[s,t]
          L.sort()
          if s==L[0]:
            u2[i+1][0]+=1
    else:
      for x in range(1,y):
        if x<int(T[0]):
          u2[1][0]+=1
        elif x==int(T[0]):
          u2[1][1]+=1
    w+=S[i]
    u=u2.copy()
  for i in range(1,N+1):
    result+=u[i][0]+u[i][1]
  L=[S,T]
  L.sort()
  if S==L[0]:
    result+=1
  print(result)
  
        
0