提交时间:2024-08-20 21:28:11

运行 ID: 173554

#include <bits/stdc++.h> using namespace std; const int N = 5e6 + 5; int f[N * 2], n, m, r; char c; signed main() { ios :: sync_with_stdio(false); cin >> n >> m; r = n; for(int i = 1; i <= n; ++i) cin >> c, f[i] = c - '0'; while(m --) { cin >> c; if(c == '*') f[++ r] = 0; else if(c == '+') ++ f[r]; else if(c == '-') -- f[r]; else f[r - 1] += f[r] >> 1, --r; } for(int i = r; i > 1; --i) { f[i - 1] += f[i] >> 1; f[i] = f[i] & 1; } for(int i = 1; i <= r; ++i) cout << f[i]; cout << "\n"; return 0; }