結果

問題 No.2265 Xor Range Substring Sum Query
ユーザー とりゐとりゐ
提出日時 2023-03-09 14:09:39
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,168 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 81,932 KB
実行使用メモリ 387,716 KB
最終ジャッジ日時 2023-10-25 05:06:13
合計ジャッジ時間 34,357 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,432 KB
testcase_01 AC 37 ms
53,432 KB
testcase_02 AC 51 ms
63,560 KB
testcase_03 AC 79 ms
75,444 KB
testcase_04 AC 4,835 ms
385,492 KB
testcase_05 AC 4,867 ms
387,024 KB
testcase_06 AC 4,811 ms
387,716 KB
testcase_07 AC 4,895 ms
385,820 KB
testcase_08 AC 4,845 ms
386,024 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
input=lambda :stdin.readline()[:-1]

mod=998244353

n=int(input())
N=1<<n
S=input()
m=n//2
node=[[(0,0)]*N for i in range(m+1)]

pow11=[1]*(N+1)
pow2=[1]*(N+1)
for i in range(1,N+1):
  pow11[i]=pow11[i-1]*11%mod
  pow2[i]=pow2[i-1]*2%mod

for i in range(N):
  node[0][i]=(int(S[i]),1)

def calc(L,R):
  num=L[0]*pow11[R[1]]+R[0]*pow2[L[1]]
  size=L[1]+R[1]
  return (num%mod,size)

def merge(i,j,L,R):
  node[i][j]=calc(node[i-1][L],node[i-1][R])

for i in range(m):
  for j in range(N):
    L=j
    R=j^(1<<i)
    merge(i+1,j,L,R)

q=int(input())
for _ in range(q):
  query=list(map(int,input().split()))
  
  if query[0]==1:
    x=int(query[1])
    y=query[2]
    node[0][x]=(int(y),1)
    
    for i in range(m):
      s=1<<i
      l=(x//(2*s))*2*s
      r=l+2*s
      for j in range(l,r):
        L=j
        R=j^(1<<i)
        merge(i+1,j,L,R)
  
  else:
    L,R,x=query[1:]
    R+=1
    res=(0,0)
    
    s=(1<<m)
    while L<R and L%s!=0:
      res=calc(res,node[0][L^x])
      L+=1
          
    while L+s<=R:
      res=calc(res,node[m][L^x])
      L+=s

    while L<R:
      res=calc(res,node[0][L^x])
      L+=1
    
    print(res[0])
0