QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#692608 | #7894. Many Many Heads | Traveler# | WA | 0ms | 3836kb | C++20 | 874b | 2024-10-31 14:46:59 | 2024-10-31 14:46:59 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 10;
string s;
bool flag1,flag2;
void solve()
{
cin >> s;
int n = s.size();
s = "#" + s;
flag2 = flag1 = false;
for(int i = 1; i <= n - 1; i ++)
{
if(s[i] == s[i+1] && s[i] == '(' || s[i] == ')')
{
if(flag1){
cout <<"No\n";
return;
}
else flag1 = 1;
}
if(s[i] == s[i+1] && s[i] == '[' || s[i] == ']'){
if(flag2){
cout <<"No\n";
return;
}
else flag2 = 1;
}
}
cout << "Yes\n";
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
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: 3836kb
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: 3556kb
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: 3560kb
input:
15134 ][ )( )([[ [)([ )][) ]])( ([]([] ]]))][ [([](] ()[))] ][(]]( ([()[) ()[](( [)([)( ]]([[)]] )[()])]] ))[](([] ](([((]] ))[)][)[ [)])([(] [()[]))[ )][(]()] [[((]()] ((]])[[) ])(](]]) )]]()[]( ([)[])]) [[)[()]( ([[)[[() [[)([])) [)[[)[() ))[(([)( ()][)[](]] [()]([[([[ )[]))][)][ )]([]([(][ [])])(...
output:
Yes Yes Yes Yes Yes No Yes No Yes No No Yes No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No N...
result:
wrong answer expected YES, found NO [6th token]