记录编号 369378 评测结果 AAAAAAAAAA
题目名称 调试LED灯 最终得分 100
用户昵称 Gravatarrewine 是否通过 通过
代码语言 C++ 运行时间 0.099 s
提交时间 2017-02-09 07:28:49 内存使用 0.31 MiB
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
#include <bitset>
#include <algorithm>

#define int long long
using namespace std;

char ch,B[1<<15],*S=B,*T=B;
#define getc() (S==T&&(T=(S=B)+fread(B,1,1<<15,stdin),S==T)?0:*S++)
#define isd(c) (c>='0'&&c<='9')
int aa,bb;int read(){
	while(ch=getc(),!isd(ch)&&ch!='-');ch=='-'?aa=bb=0:(aa=ch-'0',bb=1);
	while(ch=getc(),isd(ch))aa=aa*10+ch-'0';return bb?aa:-aa;
}
inline char getcc() {char c;while((c=getc())==' ' || c=='\n');return c;}

int L,m,x,casa,cas1,cas2;

signed main() {
	freopen("testled.in","r",stdin);
	freopen("testled.out","w",stdout);
	L = read(); char c;
	for (int i = 1; i <= L; i++) {
		c = getcc();
		x = (x<<1LL)|(c=='1');
    }
	m = read();
	casa = (1LL<<L)-1LL;
	for (int i = 1,t = 1; i <= L; i++,t <<= 1)
     i&1 ? cas1|=t : cas2|=t;
	for (int i = 1; i <= m; i++) {
		c = getcc();
		if(c == 'a') x = casa;
		else if(c == 'b') x = 0;
		else if(c == 'c') x = ~x;
		else if(c == '1') x ^= cas1;
		else if(c == '2') x ^= cas2;
		else {
			c -= '0';
			x |= ((1<<c)-1);
			x &= ((1<<L-c)-1);
		}
	}
	int sum = 0;
	int t = (1ll<<(L-1));
	while(L) {
		putchar(x&t?'1':'0');
		sum += x&t?1:0;
		t >>= 1;L--;
	}
	printf("\n%d",sum);
	return 0;
}