QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#604500 | #7894. Many Many Heads | fls | WA | 3ms | 3780kb | C++20 | 1.6kb | 2024-10-02 11:28:17 | 2024-10-02 11:28:18 |
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, 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]