QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#276332#7894. Many Many HeadsyimonWA 0ms3404kbC++11620b2023-12-05 19:59:232023-12-05 19:59:24

Judging History

你现在查看的是最新测评结果

  • [2023-12-05 19:59:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3404kb
  • [2023-12-05 19:59:23]
  • 提交

answer

#include<iostream>
#include<cmath>
#include<algorithm>
typedef long long ll;
using namespace std;
string s;
ll f = 0;
void check()
{
	f = 0;
	ll l = 0, r = s.size() - 1;
	while (l < r)
	{
		if (s[l] != s[r]) f = 1;
		l++; r--;
	}
}
signed main()
{
	ll t;
	cin >> t;
	while (t--)
	{
		string res = "YES";
		cin >> s;
		for (int i = 0; i <= s.size() - 1; i++)
		{
			if (s[i] == ')') s[i] = '(';
			if (s[i] == '[') s[i] = ']';
		}
		check();
		if (f == 0)
		{
			for (int i = 1; i < s.size() / 2; i++)
			{
				if (s[i] == s[i - 1]) res = "NO";
			}
		}
		cout << res << endl;
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3404kb

input:

6
))
((()
[()]
()[()]()
([()])
([])([])

output:

YES
NO
YES
NO
YES
NO

result:

ok 6 token(s): yes count is 3, no count is 3

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3404kb

input:

2
(([([[([
]]))])]])]

output:

YES
YES

result:

wrong answer expected NO, found YES [2nd token]