QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#660737 | #7894. Many Many Heads | foolnine# | WA | 0ms | 3532kb | C++20 | 772b | 2024-10-20 13:04:37 | 2024-10-20 13:04:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
bool check(char c) {
if (c == '(' || c == ')') {
return true;
} else {
return false;
}
}
void solve() {
string s;
cin >> s;
bool f = check(s.front());
int ok = 1;
for (int l = 1, r = s.size() - 2; l < r; l++, r--) {
if (check(s[l]) == check(s[r]) && check(s[l]) != f) {
f = check(s[l]);
} else {
ok = 0;
}
}
if (ok) {
cout << "Yes\n";
} else {
cout << "No\n";
}
}
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
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: 3512kb
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: 3532kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]