QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#570395#7894. Many Many Headsmhw#WA 0ms3600kbC++23813b2024-09-17 15:37:202024-09-17 15:37:28

Judging History

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

  • [2024-09-17 15:37:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-09-17 15:37:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
void solve()
{
    string s;
    cin >> s;
    int n = s.size(), f1 = 0, f2 = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '(' || s[i] == ')') s[i] = '0';
        else s[i] = '1';
    }
    int l1 = -1, l2 = -1;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '0')
        {
            if ((i - l1) & 1) f1++;
            l1 = i;
        }
        else 
        {
            if ((i - l2) & 1) f2++;
            l2 = i;
        }
    }
    if (f1 >= 3 || f2 >= 3) cout << "No\n";
    else cout << "Yes\n";
}
signed main()
{
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
    int t;
    cin >> t;
    while(t--) solve();
}

/*
4
()([()])
([])([()])
([()])([()])
[]()
*/

详细

Test #1:

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

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: 3564kb

input:

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

output:

No
No

result:

wrong answer expected YES, found NO [1st token]