QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#695570 | #7894. Many Many Heads | aa1234521# | WA | 3ms | 3616kb | C++20 | 1.1kb | 2024-10-31 20:18:23 | 2024-10-31 20:18:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
string st;
vector <char> v;
void solve()
{
cin >> st;
bool flag = true;
for(int i = 0; i < st.size(); i ++ )
{
if(st[i] == ']')st[i] = '[';
if(st[i] == ')')st[i] = '(';
}
int it = 0, len = st.size();
char s1, s2;
v.clear();
s1 = st[it];
while(v.empty() || (it < len && st[it] != v.back()))
{
v.push_back(st[it ++ ]);
}
while(!v.empty() || (it < len && st[it] == v.back()))
{
v.pop_back();
it ++ ;
}
if(!v.empty())flag = false;
if(it < len)
{
v.clear();
s2 = st[it];
while(v.empty() || (it < len && st[it] != v.back()))
{
v.push_back(st[it ++ ]);
}
while(!v.empty() || (it < len && st[it] == v.back()))
{
v.pop_back();
it ++ ;
}
if(!v.empty())flag = false;
if(s1 == s2)flag = false;
}
if(it < len)flag = false;
if(flag)
{
cout << "Yes" << endl;
}
else
{
cout << "No" << endl;
}
}
int main()
{
int T;
cin >> T;
while(T -- )
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 3572kb
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: 3576kb
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 No Yes Yes No No No Yes No No No No Yes No No No Yes Yes No No Yes No No No No No No Yes No No No No No No No No No No Yes No No No No No No No No...
result:
wrong answer expected NO, found YES [106th token]