QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#276332 | #7894. Many Many Heads | yimon | WA | 0ms | 3404kb | C++11 | 620b | 2023-12-05 19:59:23 | 2023-12-05 19:59:24 |
Judging History
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;
}
}
Details
Tip: Click on the bar to expand more detailed information
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]