結果
問題 | No.2311 [Cherry 5th Tune] Cherry Month |
ユーザー |
👑 ![]() |
提出日時 | 2023-02-20 19:39:32 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,176 bytes |
コンパイル時間 | 1,030 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 420,020 KB |
最終ジャッジ日時 | 2024-12-15 19:02:13 |
合計ジャッジ時間 | 187,839 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 TLE * 30 |
ソースコード
def solve():N=int(input())A=[-1]+list(map(int,input().split()))T=int(input())F=[0]*(T+1); X=[0]*(T+1); Y=[0]*(T+1)for t in range(1,T+1):F[t],X[t],Y[t]=map(int,input().split())Question=[[] for _ in range(T+1)]Q=int(input())for q in range(Q):S,I=map(int,input().split())Question[S].append((q,I))G=[[i] for i in range(N+1)]Ans=[0]*Qfor t in range(T+1):if F[t]==1:G[X[t]].append(Y[t])G[Y[t]].append(X[t])elif F[t]==2:A[X[t]]-=Y[t]elif F[t]==3:for Z in G[X[t]]:A[Z]-=Y[t]elif F[t]==4:stack=[X[t]]seen={X[t]}while stack:Z=stack.pop()A[Z]-=Y[t]for W in G[Z]:if W not in seen:seen.add(W)stack.append(W)for q,I in Question[t]:Ans[q]=max(0, A[I])return Ans#==================================================import sysinput=sys.stdin.readlinewrite=sys.stdout.writewrite("\n".join(map(str,solve())))