QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#314221#7894. Many Many HeadshazeWA 3ms3724kbC++231.3kb2024-01-25 14:35:532024-01-25 14:35:53

Judging History

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

  • [2024-01-25 14:35:53]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3724kb
  • [2024-01-25 14:35:53]
  • 提交

answer

/*

Author: Haze

2024/1/24

*/

#include <bits/stdc++.h>

#define irep(i, l, r) for(int i = (l); i <= (r); ++ i)
#define drep(i, r, l) for(int i = (r); i >= (l); -- i)
#define IOS ios::sync_with_stdio(false), cin.tie(nullptr);
using namespace std;
typedef long long ll;

inline ll read() {
    ll s = 0;
    bool fl = false;
    char ch = (char) getchar();
    while (!isdigit(ch)) {
        if (ch == '-')fl = true;
        ch = (char) getchar();
    }
    while (isdigit(ch)) {
        s = s * 10 + (ch ^ 48);
        ch = (char) getchar();
    }
    return fl ? -s : s;
}

const int mod = 1000000000 + 7;
const int itinf = 1000000999;
const ll llinf = 2e18;
const int N = 500099;

bool solve() {
    string s;
    cin >> s;
    int n = s.length();
    vector<int>a(n);
    char ch = s[0];
    for(int i = 0; i < n; ++i, ch = s[i]){
        if(ch == '(' || ch == ')')a[i] = 1;
        else a[i] = 0;
    }
    bool fl[2] = {0, 0};
    irep(i, 0, n - 2){
        if(a[i] == a[i + 1]){
            if(fl[a[i]])return false;
            fl[a[i]] = 1;
        }
        if(a[i] == a[i + 1] && i + 2 < n && a[i] == a[i + 2])return false;
    }
    return true;
}

int main() {
    IOS
    int T;
    cin >> T;
    while (T--) {
        if(!solve())cout << "No\n";
        else cout << "Yes\n";
    }
    return 0;
}

详细

Test #1:

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

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

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: 3ms
memory: 3584kb

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]