萌新人没了,求助
查看原帖
萌新人没了,求助
220426
血色黄昏楼主2020/11/8 17:57

Rt,在考场上过了大样例,但在所有啥民间数据之类的全部抱灵,人快要没了,有神仙帮忙看看问题吗/kel

#include<bits/stdc++.h>
using namespace std;
int n, q, cnt = 0, x[100010];
string a[1000010], b;
stack<int>s;
int jie(string qaq)
{
	int an = 0;
	for(int i = 1;i < qaq.size();i ++)an = 10 * an + (qaq[i] - '0');
	return an;
}
void read()
{
	string qaq = "";
	for(int i = 0;i < b.size();i ++)
	{
		if(b[i] == ' ')
		{
			a[cnt++] = qaq;
			qaq = "";
			continue;
		}
		qaq += b[i];
	}
	a[cnt] = qaq;
}
void pss()
{
	for(int i = 0;i <= cnt;i ++)
	{
		if(a[i] == "&")
		{
			int x1, y1;
			x1 = s.top();
			s.pop();
			y1 = s.top();
			s.pop();
			s.push(x1&y1);
		}
		else if(a[i] == "|")
		{
			int x1, y1;
			x1 = s.top();
			s.pop();
			y1 = s.top();
			s.pop();
			s.push(x1|y1);
		}
		else if(a[i] == "!")
		{
			int x1;
			x1 = s.top();
			s.pop();
			s.push((!x1));
		}
		else{
			s.push(x[jie(a[i])]);
		}
	}
	cout<<s.top()<<endl;
	s.pop();
}
int main()
{
	getline(cin, b);
	read();
	cin>>n;
	for(int i = 1;i <= n;i ++)scanf("%d", &x[i]);
	cin>>q;
	for(int i = 0;i < q;i ++)
	{
		int op;
		scanf("%d", &op);
		x[op] = (!x[op]);
		pss();
		x[op] = !x[op];
	}
	return 0;
}
2020/11/8 17:57
加载中...