QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#604488 | #7894. Many Many Heads | fls | WA | 1ms | 3636kb | C++20 | 1.3kb | 2024-10-02 11:21:03 | 2024-10-02 11:21:04 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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]