萌新RE求助,第五、第十个点过不了QAQ
查看原帖
萌新RE求助,第五、第十个点过不了QAQ
303289
yogart楼主2020/5/23 22:45

我在电脑上运行,明明秒出答案鸭???

#include<iostream>
using namespace std;
int main()
{
	char a[256];
	char b;
	int i = 0, flag = 0;
	while (cin >> b)
	{
		if (b != '@')
		{
			a[i] = b; i++;
		}
		else break;
	}
	int* map = new int[i - 1];
	for (int j = 0; j < i; j++)
	{
		if (a[j] != '(' && a[j] != ')')map[j] = 0;
		else if (a[j] == '(')map[j] = 1;
		else map[j] = 2;
	}
	for (int j = 0; j < i-1; j++)
	{
		if (map[j] == 1) 
		for (int k = j + 1; k < i; k++)
		{
			if (map[k] == 2)
			{
				map[k] = 0; map[j] = 0; break;
			}
		}
	}
	for (int j = 0; j < i; j++)
		if (map[j])
		{
			flag = 1; break;
		}
	if (flag)cout << "NO";
	else cout << "YES";
	return 0;
}
2020/5/23 22:45
加载中...