QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#752240 | #7894. Many Many Heads | veg# | WA | 0ms | 3956kb | C++14 | 856b | 2024-11-15 23:16:16 | 2024-11-15 23:16:17 |
Judging History
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]