记录编号 |
598559 |
评测结果 |
AAAAWAAAAA |
题目名称 |
调试LED灯 |
最终得分 |
90 |
用户昵称 |
长安惊龙灵松 |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
0.584 s |
提交时间 |
2025-01-25 16:36:14 |
内存使用 |
5.06 MiB |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int l,sta[50],n,ans;
string s;
int main()
{
freopen("testled.in","r",stdin);
freopen("testled.out","w",stdout);
scanf("%d",&l);
cin>>s;
for(int i=1;i<=l;i++)
{
sta[i]=s[i-1]-'0';
}
scanf("%d",&n);
cin>>s;
for(int t=0;t<n;t++)
{
if(s[t]=='a')
{
for(int i=1;i<=l;i++)
sta[i]=1;
}
else if(s[t]=='b')
{
for(int i=1;i<=l;i++)
sta[i]=0;
}
else if(s[t]=='c')
{
for(int i=1;i<=l;i++)
sta[i]=1-sta[i];
}
else if(s[t]=='1')
{
for(int i=l;i>=1;i-=2)
sta[i]=1-sta[i];
}
else if(s[t]=='2')
{
for(int i=l-1;i>=1;i-=2)
sta[i]=1-sta[i];
}
else
{
int x=s[t]-'0';
for(int i=1;i<=x;i++)
{
sta[i]=0;
}
for(int i=l-x+1;i<=l;i++)
{
sta[i]=1;
}
}
}
for(int i=1;i<=l;i++)
{
ans+=sta[i];
printf("%d",sta[i]);
}
printf("\n%d",ans);
return 0;
}