QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#604500#7894. Many Many HeadsflsWA 3ms3780kbC++201.6kb2024-10-02 11:28:172024-10-02 11:28:18

Judging History

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

  • [2024-10-02 11:28:18]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3780kb
  • [2024-10-02 11:28:17]
  • 提交

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, lst;
    cin>>test;
    while(test--){
        lst = 0;
        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);
                    if(lst == 1){
                        fail = true;
                    }else{
                        lst = 1;
                    }
                }else{
                    stk.push(1);
                }
            }else{
                if(!stk.empty() && stk.top() == 2){
                    stk.pop();
                    if(stk.empty())
                        f.push_back(2);
                    if(lst == 2){
                        fail = true;
                    }else{
                        lst = 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: 0ms
memory: 3780kb

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

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

input:

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

output:

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

result:

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