QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#752240#7894. Many Many Headsveg#WA 0ms3956kbC++14856b2024-11-15 23:16:162024-11-15 23:16:17

Judging History

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

  • [2024-11-15 23:16:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3956kb
  • [2024-11-15 23:16:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
char s[100005];
int n, len, t[10];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", s);
		vector<pair<int, int> > v;
		int len = strlen(s);
		t[0] = t[1] = 0;
		for (int i = 0; i < len; ++i) {
			s[i] = (s[i] == '(' || s[i] == ')') ? 0 : 1;
			t[s[i]]++;
		}
		if ((t[0] & 1) || (t[1] & 1)) {
			puts("No");
			goto Nex;
		}			
		for (int i = 2; i < len; ++i)
			if (s[i] == s[i - 1] && s[i] == s[i - 2]) {
				puts("No");
				goto Nex;
			}
		for (int i = 0; i < len; ++i)
			if (s[i] == s[i - 1])
				v.push_back({i - 1, i});
		if (v.size() == 1 && v[0].second == len / 2) {
			puts("Yes");
			goto Nex;
		}
		if (v.size() == 2 && v[1].second - v[0].second == len / 2) {
			puts("Yes");
			goto Nex;
		}
		puts("No");
		Nex:;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3680kb

input:

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

output:

No
No

result:

wrong answer expected YES, found NO [1st token]