QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#643262#7894. Many Many HeadsyellWA 0ms3796kbC++20848b2024-10-15 20:11:532024-10-15 20:11:54

Judging History

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

  • [2024-10-15 20:11:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3796kb
  • [2024-10-15 20:11:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using LL = long long;

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    s = " " + s;

    auto check = [&](char a, char b) {
        if (a == b) {
            return true;
        }
        if ((a == '(' && b == ')') || (a == ')' && b == '(')) {
            return true;
        }
        if ((a == '[' && b == ']') || (a == ']' && b == '[')) {
            return true;
        }
        return false;
    };
    bool ok = true;
    for (int i = 1; i <= n / 2; i++) {
        if (check(s[i], s[i - 1])) {
            ok = false;
        }
    }
    cout << (ok ? "Yes\n" : "No\n");
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

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

output:

No
No

result:

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