QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#368983 | #7894. Many Many Heads | HuLiangyu# | WA | 1ms | 3804kb | C++14 | 1.5kb | 2024-03-27 18:48:36 | 2024-03-27 18:48:37 |
Judging History
answer
#include <iostream>
#include <stack>
#include <vector>
#include <string>
using namespace std;
int main() {
int T;
cin >> T;
while( T-- ) {
string S;
vector<bool> ss;
cin >> S;
ss.resize(S.size());
for (int i = 0; i < S.size(); ++ i) {
if (S[i] == '(' || S[i] == ')')
ss[i] = true;
else
ss[i] = false;
}
bool FALSE_GET = false;
bool TRUE_GET = false;
bool ANS_GET = false;
stack<bool> stk;
for (int i = 0; i < S.size(); ++ i) {
if (stk.empty() || ss[i] != stk.top()) {
stk.push(ss[i]);
}
else {
stk.pop();
if (stk.empty()) {
if (ss[i]) {
if (TRUE_GET) {
cout << "No" << endl;
ANS_GET = true;
break;
}
TRUE_GET = true;
}
else {
if (FALSE_GET) {
cout << "No" << endl;
ANS_GET = true;
break;
}
FALSE_GET = true;
}
}
}
}
if (!ANS_GET) {
cout << "Yes" << endl;
}
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
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: 1ms
memory: 3796kb
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: 3564kb
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]