QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#748841 | #7894. Many Many Heads | surenjamts# | WA | 16ms | 3596kb | C++20 | 1.0kb | 2024-11-14 21:39:04 | 2024-11-14 21:39:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
signed main(){
int t;
string s;
cin >> t;
map < char, int > mp;
mp[ '(' ] = mp[')'] = 1;
mp[ '[' ] = mp[']'] = -1;
while( t -- ){
cin >> s;
int cntp = 0, cntd = 0;
vector < char > c;
for(int i = 0; i < s.size(); i ++ ){
if( c.size() == 0 ){
c.pb( s[i] );
continue;
}
if( mp[ c[ c.size()-1 ] ] == mp[ s[i] ] ){
c.pop_back();
if( c.size() == 0 ){
if( mp[ s[i] ] == 1 ){
cntp ++;
}else{
cntd ++;
}
}
}else{
c.pb( s[i] );
}
}
if( cntp >= 2 || cntd >= 2 ){
cout << "No\n";
}else
cout << "Yes\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3572kb
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: 3596kb
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: 16ms
memory: 3444kb
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]