记录编号 580596 评测结果 AAAAAAAAAA
题目名称 调试LED灯 最终得分 100
用户昵称 Gravatar┭┮﹏┭┮ 是否通过 通过
代码语言 C++ 运行时间 0.720 s
提交时间 2023-07-25 12:04:26 内存使用 4.59 MiB
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int n,m,ans;
bool l[110];
char ch;
int main(){
    freopen("testled.in","r",stdin);
    freopen("testled.out","w",stdout);
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        cin>>ch;
        l[i] = ch - '0';
    }
    scanf("%d",&m);
    for(int i = 1;i <= m;i++){
        cin>>ch;
        if(ch == 'a'){
            for(int j = 1;j <= n;j++)l[j] = 1;
        }
        else if(ch == 'b'){
            for(int j = 1;j <= n;j++)l[j] = 0;
        }
        else if(ch == 'c')
            for(int j = 1;j <= n;j++)l[j] = !l[j];
        else if(ch == '1'){
            for(int j = n;j >= 1;j -= 2)l[j] = !l[j];
        }
        else if(ch == '2')
            for(int j = n-1;j >= 1;j -= 2)l[j] = !l[j];
        else if(ch >= '3' && ch <= '9'){
            for(int j = n-ch+'0'+1;j <= n;j++)l[j] = 1;
            for(int j = 1;j <= ch-'0';j++)l[j] = 0;
        }
    }
    for(int i = 1;i <= n;i++){
        if(l[i])ans++;
        printf("%d",l[i]);
    }
    printf("\n%d\n",ans);
    
    return 0;
    
}