QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#278018#7894. Many Many Headsucup-team1338#WA 1ms3432kbC++20787b2023-12-07 10:48:262023-12-07 10:48:26

Judging History

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

  • [2023-12-07 10:48:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3432kb
  • [2023-12-07 10:48:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef long long ll;

int val(char c)
{
    if (c == '(' || c == ')')
        return 0;
    return 1;
}
void solve()
{
    string s;
    cin >> s;
    int n = s.length();
    s = '\0' + s;

    for (int i = 1; i <= n / 2; ++i)
    {
        if (val(s[i]) != val(s[n - i + 1]))
        {
            cout << "No\n";
            return;
        }
        if (i > 1 && val(s[i]) == val(s[i - 1]))
        {
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int T;
    cin >> T;
    while (T--)
        solve();
    // solve();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3432kb

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

input:

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

output:

No
No

result:

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