0分求助
查看原帖
0分求助
1409685
zhaoyikuan_kkk楼主2024/8/7 12:31

很崩溃啊这个测试点居然只对了一部分,而且也没有超过内存限制, 更可恶的是居然对的测试点也没给分 。麻烦各路大神帮忙看看哪里逻辑短路出现问题吧

#include <iostream>
#include <stack>
using namespace std;
int main()
{	
	stack<int> a;
	stack<int> b;
	stack<int> c;
	int s[1001],n, m;
	cin>>n>>m;
	for(int i = 1; i <= n; i++)
	{
		cin >> s[i];
	}
	for(int i = 1; i <= m; i++)
	{
		int v;
		cin>>v;
		a.push(v);
		cin>>v;
		b.push(v);
		cin>>v;
		c.push(v);
	}
	while(!a.empty())
	{
		if(a.top()==1) s[b.top()] -= s[c.top()];
		if(a.top()==2) s[b.top()] /= s[c.top()];
		a.pop();
		b.pop();
		c.pop();
	}
	for(int i = 1; i <= n; i++)
	{
		cout<<s[i]<<" ";
	}
	return 0;
}

最多就用了3个栈1个数组3个变量,不能超出内存吧

2024/8/7 12:31
加载中...