QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#367750#7894. Many Many Headsucup-team1001WA 0ms3808kbC++231.2kb2024-03-26 13:08:462024-03-26 13:08:46

Judging History

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

  • [2024-03-26 13:08:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3808kb
  • [2024-03-26 13:08:46]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

#ifndef ONLINE_JUDGE
#include "test.h"
#include "dbg.h"
#else
#define debug(...) 42
#define debug_assert(...) 42
#endif


#define IOS ios::sync_with_stdio(0),cin.tie(0)

using ll = long long;
using ull = unsigned long long;

#define endl '\n'
#define int ll

using VI = vector<int>;
using VII = vector<VI>;
using PII = pair<int, int>;
const int inf = 1e18;
const int mod = 1e9 + 7;

void init() {
}


void solve() {
    string s;
    cin >> s;
    for (auto&i: s) {
        if (i == '(') {
            i = ')';
        }
        if (i == '[') {
            i = ']';
        }
    }
    debug(s);
    int l = s.size();
    if (l % 2) {
        cout << "No" << endl;
        return;
    }
    int mid = l / 2;
    s = '#' + s;
    for (int i = 0; i < l / 2; i++) {
        if (s[mid - i] != s[mid + 1 + i]) {
            cout << "No" << endl;
            return;
        }
        if (s[mid - i - 1] == s[mid - i]) {
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;
}

signed main() {
    IOS;
    init();
    // debug(1);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

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

output:

No
No

result:

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