比赛 位运算及及其应用题单 评测结果 WWWWWWWWWW
题目名称 调试LED灯 最终得分 0
用户昵称 Asher 运行时间 1.039 s
代码语言 C++ 内存使用 3.28 MiB
提交时间 2025-01-25 15:44:31
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
int li[35];
char ch, s;
int main() 
{
	freopen("testled.in","r",stdin);
	freopen("testled.out","w",stdout);
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> s;
		if(s == '1')
			li[i] = 1;
	}
	cin >> m;
	for(int i = 1; i <= m; i++) 
	{
		cin >> ch;
		if(ch == 'a')
			for(int j = 1; j <= n; j++) 
				li[j] = 1;
		else if(ch == 'b')
			for(int j = 1; j <= n; j++)
				li[j] = 0;
		else if(ch == 'c') 
			for(int j = 1; j <= n; j++) 
				li[j] = (li[j] == 1) ? 0 : 1;
		//
		else if(ch == '1') 
			for(int j = n; j >= 1; j -= 2)
				li[j] = (li[j] == 1) ? 0 : 1;
		else if(ch == '2') 
			for(int j = n - 1; j >= 1; j -= 2)
				li[j] = (li[j] == 1) ? 0 : 1;
		else 
		{
			for(int j = 1; j <= (ch - '0'); j++)
				li[j] = 1;
			for(int j = n; j >= (n - ch + '0' + 1); j--)
				li[j] = 0;
		}
	}
	for(int i = 1; i <= n; cout << !li[i], i++)
		if(li[i] != 1)
			ans++;
	cout << '\n' << ans;
	return 0;
}