QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#556403#7894. Many Many HeadsHTensorWA 0ms3612kbC++171.4kb2024-09-10 17:43:132024-09-10 17:43:14

Judging History

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

  • [2024-09-10 17:43:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-09-10 17:43:13]
  • 提交

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;

template class stack<int>;

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

    int lst = -1;
    stack<int> s;
    for(auto c : str) {
        c = (c == '[' || c == ']') ? '[' : '(';
        if(s.empty()) {
            s.push(c);
            continue;
        }

        if(s.top() == c) {
            int now = (c == '[' ? 1 : 0);
            if(now == lst) {
                ans.push_back(1); ans.push_back(1); ans.push_back(1);
                break;
            }
            lst = now;
            s.pop();
        } else s.push(c);

        if(s.empty()) {
            ans.push_back(c);
            lst = -1;
        }
    }

    // assert(ans.size() != 0);

    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
))
((()
[()]
()[()]()
([()])
([])([])

1
([])[()]

*/

詳細信息

Test #1:

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

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

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: 0ms
memory: 3612kb

input:

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

output:

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

result:

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