QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#556357#7894. Many Many HeadsHTensorWA 4ms3624kbC++171.5kb2024-09-10 17:15:582024-09-10 17:16:01

Judging History

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

  • [2024-09-10 17:16:01]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3624kb
  • [2024-09-10 17:15:58]
  • 提交

answer

#include <bits/stdc++.h>
#define dd(x) cout << #x << "\n"
#define d(x) cout << #x  << ": " << x << "\n"
using namespace std;
#define int long long
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using a3 = array<int, 3>;
const int inf = 0x3f3f3f3f3f3f3f3fLL;

void solve() {
    string str; cin >> str;
    int n = str.size();
    vector<int> ans;

    int a1 = 0, a2 = 0, lst = -1;
    for(auto c : str) {
        if(c == '[' || c == ']') {
            if(!a1) ++a1;
            else {
                --a1;
                if(lst == 1) {
                    ans.push_back(1); ans.push_back(1); ans.push_back(1);
                    break;
                }
            }
        } else {
            if(!a2) ++a2;
            else {
                --a2;
                if(lst == 0) {
                    ans.push_back(1); ans.push_back(1); ans.push_back(1);
                    break;
                }
            }
        }

        if(!a1 && !a2) {
            ans.push_back(c == '[' ? 1 : 0);
            lst = -1;
        }
    }

    if(ans.size() > 2) {
        cout << "No\n";
    } else if(ans.size() == 1) {
        cout << "Yes\n";
    } else {
        cout << (ans[0] == ans[1] ? "No\n" : "Yes\n");
    }
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int T; cin >> T;
    while(T--) solve();
    return 0;
}

/*

6
))
((()
[()]
()[()]()
([()])
([])([])

*/

详细

Test #1:

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

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

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

input:

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

output:

Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
No
Yes
Yes
No
Yes
No
No
No
No
Yes
No
No
No
No
No
No
No
Yes
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
Yes
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...

result:

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