結果
| 問題 |
No.265 数学のテスト
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2022-10-18 05:05:20 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,328 bytes |
| コンパイル時間 | 81 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 12,544 KB |
| 最終ジャッジ日時 | 2024-06-28 15:46:26 |
| 合計ジャッジ時間 | 2,559 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 RE * 2 |
ソースコード
N=int(input())
d=int(input())
S=input().strip()
D=[-1]*N
Q=[]
for i in range(len(S)):
if S[i]=="d":
Q.append(i)
elif S[i]=="}":
D[Q[-1]]=i
Q.pop()
def calc(L,R):
ANS=[0]*12
ind=L
score=1
dim=0
while ind<=R:
#print(ANS,ind)
if S[ind]=="d":
x=D[ind]
X=diff(calc(ind+2,x-1))
for i in range(len(X)):
ANS[i]+=X[i]
ind=x+1
score=1
dim=0
if ind<len(S) and S[ind]=="+":
ind+=1
elif S[ind]=="x":
dim+=1
if ind+1<len(S) and S[ind+1]=="*":
ind+=2
else:
ind+=1
elif "1"<=S[ind]<="9":
x=int(S[ind])
score*=x
if ind+1<len(S) and S[ind+1]=="*":
ind+=2
else:
ind+=1
else:
ANS[dim]+=score
score=1
dim=0
ind+=1
if ind==R+1 and S[ind-1]!="}":
ANS[dim]+=score
break
return ANS
def diff(A):
#print("!",A)
ANS=[0]*(len(A)-1)
for i in range(len(A)):
ANS[i-1]=i*A[i]
#print(ANS)
return ANS
print(*calc(0,len(S)-1)[:d+1])
titia