結果

問題 No.1996 <><
ユーザー googol_S0googol_S0
提出日時 2022-07-01 21:34:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,791 ms / 2,000 ms
コード長 1,258 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 104,088 KB
最終ジャッジ日時 2023-08-17 08:54:51
合計ジャッジ時間 23,975 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
71,508 KB
testcase_01 AC 84 ms
71,712 KB
testcase_02 AC 85 ms
71,744 KB
testcase_03 AC 111 ms
77,428 KB
testcase_04 AC 84 ms
71,600 KB
testcase_05 AC 84 ms
71,512 KB
testcase_06 AC 84 ms
71,852 KB
testcase_07 AC 86 ms
71,512 KB
testcase_08 AC 161 ms
78,400 KB
testcase_09 AC 107 ms
77,364 KB
testcase_10 AC 149 ms
78,732 KB
testcase_11 AC 969 ms
91,576 KB
testcase_12 AC 1,741 ms
101,500 KB
testcase_13 AC 1,747 ms
104,088 KB
testcase_14 AC 1,791 ms
104,008 KB
testcase_15 AC 1,581 ms
99,692 KB
testcase_16 AC 1,489 ms
99,300 KB
testcase_17 AC 1,571 ms
99,608 KB
testcase_18 AC 1,055 ms
92,732 KB
testcase_19 AC 1,091 ms
94,416 KB
testcase_20 AC 1,059 ms
92,612 KB
testcase_21 AC 1,339 ms
95,412 KB
testcase_22 AC 1,498 ms
98,576 KB
testcase_23 AC 229 ms
79,984 KB
testcase_24 AC 1,007 ms
90,388 KB
testcase_25 AC 586 ms
82,520 KB
testcase_26 AC 862 ms
88,248 KB
testcase_27 AC 323 ms
80,488 KB
testcase_28 AC 128 ms
78,452 KB
testcase_29 AC 513 ms
82,212 KB
testcase_30 AC 178 ms
78,376 KB
testcase_31 AC 339 ms
79,804 KB
testcase_32 AC 160 ms
78,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import *
mod=10**9+7
def init(N,node,A,unit,func):
  n=1
  while n<N:
    n<<=1
  for i in range(n*2-1):
    if len(node)<=i:
      node.append(deepcopy(unit))
    else:
      node[i]=deepcopy(unit)
  for i in range(len(A)):
    node[n-1+i]=deepcopy(A[i])
  for i in range(n-2,-1,-1):
    node[i]=func(node[(i<<1)+1],node[(i<<1)+2])
  node.append(func)
  node.append(unit)
  node.append(n)

def upd(node,x,a):
  y=node[-1]+x
  node[y-1]+=a
  while y>1:
    y=y>>1
    node[y-1]=node[-3](node[(y<<1)-1],node[y<<1])

def query(node,l,r):
  x,y=l,r
  z=node[-1]-1
  rr=deepcopy(node[-2])
  rl=deepcopy(node[-2])
  while True:
    if x==y:
      return node[-3](rl,rr)
    if x&1:
      rl=node[-3](rl,node[x+z])
      x+=1
    if y&1:
      rr=node[-3](node[y+z-1],rr)
    if z==0:
      return node[-3](rl,rr)
    x>>=1
    y>>=1
    z>>=1

N,K=map(int,input().split())
A=list(map(int,input().split()))
S=sorted(set(A))
D=dict()
for i in range(len(S)):
  D[S[i]]=i
for i in range(N):
  A[i]=D[A[i]]
S=input()
DP=[1]*N
for i in range(K):
  seg=[]
  init(N,seg,[],0,lambda x,y:x+y)
  for j in range(N):
    v=DP[j]
    if S[i]=='<':
      DP[j]=query(seg,0,A[j])%mod
    else:
      DP[j]=query(seg,A[j]+1,N)%mod
    upd(seg,A[j],v)
print(sum(DP)%mod)
0