QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#604488#7894. Many Many HeadsflsWA 1ms3636kbC++201.3kb2024-10-02 11:21:032024-10-02 11:21:04

Judging History

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

  • [2024-10-02 11:21:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3636kb
  • [2024-10-02 11:21:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define qmx(a,b) a<b?b:a
#define qmn(a,b) a>b?b:a
#define ll long long
#define fr first
#define se second

string str;

stack <int> stk;

vector <int> f;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    bool fail;
    int test;
    cin>>test;
    while(test--){
        f.clear();
        fail = false;
        cin >> str;
        for(int i = 0 ; i < (int)str.size() ; i++){
            if(str[i] == '(' || str[i] == ')'){
                if(!stk.empty() && stk.top() == 1){
                    stk.pop();
                    if(stk.empty())
                        f.push_back(1);
                }else{
                    stk.push(1);
                }
            }else{
                if(!stk.empty() && stk.top() == 2){
                    stk.pop();
                    if(stk.empty())
                        f.push_back(2);
                }else{
                    stk.push(2);
                }
            }
        }
        if(f.size() >= 3){
            fail = true;
        }else{
            if(f.size() == 2 && f[0] == f[1]){
                fail = true;
            }
        }
        if(!fail)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}

詳細信息

Test #1:

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

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

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

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]