QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#643262 | #7894. Many Many Heads | yell | WA | 0ms | 3796kb | C++20 | 848b | 2024-10-15 20:11:53 | 2024-10-15 20:11:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void solve() {
string s;
cin >> s;
int n = s.size();
s = " " + s;
auto check = [&](char a, char b) {
if (a == b) {
return true;
}
if ((a == '(' && b == ')') || (a == ')' && b == '(')) {
return true;
}
if ((a == '[' && b == ']') || (a == ']' && b == '[')) {
return true;
}
return false;
};
bool ok = true;
for (int i = 1; i <= n / 2; i++) {
if (check(s[i], s[i - 1])) {
ok = false;
}
}
cout << (ok ? "Yes\n" : "No\n");
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 3796kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]