QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#314660#7894. Many Many Headsucup-team1087WA 4ms3928kbC++141.8kb2024-01-26 02:28:252024-01-26 02:28:25

Judging History

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

  • [2024-01-26 02:28:25]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3928kb
  • [2024-01-26 02:28:25]
  • 提交

answer

#include <iostream>
#include <iomanip>
#include <cmath>
#include <climits>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <set>
#include <map>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int N = 1e5 + 1;

char str[N + 1];
bool c[CHAR_MAX], a[N];

void solve() {
    scanf("%s", str + 1);
    int len = (int)strlen(str + 1);
    for (int i = 1; i <= len; ++i) {
        a[i] = c[str[i]];
    }
    vector<bool> stk;
    for (int i = 1; i <= len; ++i) {
        if (!stk.empty() && stk.back() == a[i]) {
            stk.pop_back();
        } else {
            stk.push_back(a[i]);
        }
    }
    if (!stk.empty()) {
        puts("No");
        return ;
    }
    for (int i = 1; i <= len - 2; ++i) {
        if (a[i] == a[i + 1] && a[i + 1] == a[i + 2]) {
            puts("No");
            return ;
        }
    }
    int cnt0 = 0, cnt1 = 0;
    for (int i = 1; i <= len - 1; ++i) {
        if (a[i] == a[i + 1]) {
            if (a[i] == 0 && a[i + 1] == 0) {
                if (++cnt0 >= 2) {
                    puts("No");
                    return ;
                }
            } else {
                if (++cnt1 >= 2) {
                    puts("No");
                    return ;
                }
            }
            ++i;
        }
    }
    puts("Yes");
}

int main(int argc, const char * argv[]) {
    c['['] = c[']'] = false;
    c['('] = c[')'] = true;
    
    int T;
    scanf("%d", &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: 3928kb

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

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: 4ms
memory: 3704kb

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]