比赛 2020级再出发之位运算 评测结果 WWAWAAAAAW
题目名称 调试LED灯 最终得分 60
用户昵称 ┭┮﹏┭┮ 运行时间 0.562 s
代码语言 C++ 内存使用 3.49 MiB
提交时间 2023-07-25 18:30:49
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
long long L,n,ans[10010],ss;
long long s,s1,s2;
char ch;
int main(){
    freopen("testled.in","r",stdin);
    freopen("testled.out","w",stdout);
    cin>>L;
    for(int i = 0;i < L;i++){
        if(i % 2){
            s2 += (1ll << i);
        }
        else{
            s1 += (1ll << i);
        }
    }
    for(int i = 1;i <= L;i++){
        cin>>ch;
        s <<= 1ll;
        s += ch - '0';
    }
    //cout<<s<<endl;
    cin>>n;
    for(int i = 1;i <= n;i++){
        cin>>ch;
        if(ch == 'a')s = s | ((1 << L) - 1);
        else if(ch == 'b')s = 0;
        else if(ch == 'c')s ^= ((1 << L) - 1);
        else if(ch == '1')s ^= s1;
        else if(ch == '2')s ^= s2;
        else if(ch >= '3' && ch <= '9'){
            int x = ch - '0';
            s = s | ((1ll << x) - 1);
            s = s & (((1ll << (L-x)) -1)) ;
        }
    }
    //cout<<s<<endl;
    for(int i = 1;i <= L;i++){
        if(s & 1)ss++;
        ans[i] = s & 1;
        s >>= 1ll;
    }
    for(int i = L;i >= 1;i--){
        cout<<ans[i]; 
    }
    cout<<endl<<ss<<endl;
    
    return 0;
}