QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#692182#7894. Many Many Headsljljljlj#WA 3ms3836kbC++20853b2024-10-31 13:59:412024-10-31 13:59:42

Judging History

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

  • [2024-10-31 13:59:42]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3836kb
  • [2024-10-31 13:59:41]
  • 提交

answer

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
using i64 = long long;
const int inf = 1e9;
void solve()
{
    string s;
    cin >> s;
    int pre1 = 0, pre2 = 0, cnt = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '(' || s[i] == ')')
            pre1 += 1;
        else
            pre2 += 1;
        if ((pre1 == 0 && pre2 == 4) || (pre2 == 0 && pre1 == 4))
        {
            cout << "No\n";
            return;
        }
        if (pre1 != 0 && pre2 != 0 && (pre1 % 2 == 0) && (pre2 % 2 == 0))
            cnt++;
    }
    if (cnt > 1)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

int main()
{
    ios::sync_with_stdio(false), cin.tie(0);
    int T = 1;
    cin >> T;
    while (T--)
        solve();
    // system("pause");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 0ms
memory: 3836kb

input:

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

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #3:

score: -100
Wrong Answer
time: 3ms
memory: 3616kb

input:

15134
][
)(
)([[
[)([
)][)
]])(
([]([]
]]))][
[([](]
()[))]
][(]](
([()[)
()[]((
[)([)(
]]([[)]]
)[()])]]
))[](([]
](([((]]
))[)][)[
[)])([(]
[()[]))[
)][(]()]
[[((]()]
((]])[[)
])(](]])
)]]()[](
([)[])])
[[)[()](
([[)[[()
[[)([]))
[)[[)[()
))[(([)(
()][)[](]]
[()]([[([[
)[]))][)][
)]([]([(][
[])])(...

output:

Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
N...

result:

wrong answer expected YES, found NO [7th token]