QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#660737#7894. Many Many Headsfoolnine#WA 0ms3532kbC++20772b2024-10-20 13:04:372024-10-20 13:04:38

Judging History

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

  • [2024-10-20 13:04:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3532kb
  • [2024-10-20 13:04:37]
  • 提交

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;
}

詳細信息

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]