QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#298339#7894. Many Many Headsucup-team1516#WA 5ms3544kbC++171.4kb2024-01-06 00:32:102024-01-06 00:32:11

Judging History

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

  • [2024-01-06 00:32:11]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3544kb
  • [2024-01-06 00:32:10]
  • 提交

answer

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline double time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q; cin >> q;
    while (q--) {
        string s; cin >> s;
        for (auto &c: s) {
            if (c == ')') c = '(';
            if (c == ']') c = '[';
        }
        bool ok = true;
        int bit = 0;
        int n = s.size();
        for (int i = 0; i < n; ) {
            int j = i;
            int cnt = 0;
            while (i < n and s[i] == s[j]) {
                i += 1;
                cnt += 1;
            }
            if (cnt >= 3) ok = false;
            if (cnt == 2) {
                if (s[j] == '(') {
                    if (bit&1) ok = false;
                    bit ^= 1;
                }
                else {
                    if (bit&2) ok = false;
                    bit ^= 2;
                }
            }
        }
        if (ok) cout << "Yes" << "\n";
        else cout << "No" << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 0ms
memory: 3432kb

input:

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

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #3:

score: -100
Wrong Answer
time: 5ms
memory: 3544kb

input:

15134
][
)(
)([[
[)([
)][)
]])(
([]([]
]]))][
[([](]
()[))]
][(]](
([()[)
()[]((
[)([)(
]]([[)]]
)[()])]]
))[](([]
](([((]]
))[)][)[
[)])([(]
[()[]))[
)][(]()]
[[((]()]
((]])[[)
])(](]])
)]]()[](
([)[])])
[[)[()](
([[)[[()
[[)([]))
[)[[)[()
))[(([)(
()][)[](]]
[()]([[([[
)[]))][)][
)]([]([(][
[])])(...

output:

Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
No
Yes
No
No
No
Yes
No
No
Yes
Yes
No
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No...

result:

wrong answer expected YES, found NO [7th token]