- 买铅笔
题解(求管理员大大勿封)
- 2024-8-16 9:13:02 @
AC记录 https://hydro.ac/d/atcoder/record/66bea7623f788cb34ad04898
#include <bits/stdc++.h>
#include <algorithm>
#define endl '\n';
const int N = 1e6 + 10;
const int M = 2e6 + 10;
const int P = 998244353;
const int Base = 3221225477;
const int INF = 0x3f3f3f3f3f3f3f3f;
int mod(int x)
{
return x % P;
}
using namespace std;
char a[N];
string s;
signed main()
{
cin >> s;
int pos = 0;
for(int i = 0;i < s.size();i++)
{
if(s[i] == '1')
{
a[pos] = '1';
pos++;
}else if(s[i] == '0')
{
a[pos] = '0';
pos++;
}else if(s[i] == 'B')
{
if(pos > 0)
{
a[pos] = ' ';
pos--;
}else if(pos <= 0)
{
pos = 0;
}
}
}
for(int i = 0;i < pos;i++)
{
cout << a[i];
}
return 0;
}
0 条评论
目前还没有评论...
信息
- ID
- 431
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- 递交数
- 30
- 已通过
- 18
- 上传者