社区讨论
80分求调
P11375[GESP202412 六级] 树上游走参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @min9ja80
- 此快照首次捕获于
- 2025/12/01 22:47 3 个月前
- 此快照最后确认于
- 2025/12/03 22:20 3 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
stack <char> a;
stack <char> a_nums;
unsigned long long int n,s;
char string_now;
int main()
{
cin>>n>>s;
for(int i=1;i<=n;i++)
{
cin>>string_now;
if(!a.empty()&&(a.top()!='U')&&string_now=='U')
{
a.pop();
}
else
{
a.push(string_now);
}
}
while(a.empty()==0)
{
a_nums.push(a.top());
a.pop();
}
while(a_nums.empty()==0)
{
if(a_nums.top()=='U')
{
s/=2;
}
else if(a_nums.top()=='L')
{
s*=2;
}
else
{
s=s*2+1;
}
a_nums.pop();
}
cout<<s;
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...