QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#278875#7894. Many Many Headsucup-team1508#WA 1ms3468kbC++20876b2023-12-07 21:47:122023-12-07 21:47:13

Judging History

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

  • [2023-12-07 21:47:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3468kb
  • [2023-12-07 21:47:12]
  • 提交

answer

#include<bits/stdc++.h>
#define F(i, a, b) for(int i = a; i <= b; i ++)
#define Fd(i, a, b) for(int i = a; i >= b; i --)
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;

const int N = 105;

int n;

void sol() {
    string s; cin >> s; n = s.size();
    s = " " + s;
    F(i, 1, n) {
        if(s[i] == '(' || s[i] == ')') s[i] = '(';
        else s[i] = '[';
    }
    if(s[n / 2] != s[n / 2 + 1]) {
        cout << "No\n";
        return;
    }
    F(i, 2, n / 2) if(s[i] == s[i - 1]) {
        cout << "No\n";
        return;
    } 
    F(i, n / 2 + 1, n - 1) if(s[i] == s[i + 1]) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t; cin >> t;
    F(i, 1, t) sol();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 1ms
memory: 3468kb

input:

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

output:

No
No

result:

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