QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#752176 | #7894. Many Many Heads | veg# | WA | 0ms | 3820kb | C++14 | 860b | 2024-11-15 22:32:47 | 2024-11-15 22:32:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
char s[maxn];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%s",s+1);
int cnt1=0,cnt2=0,n=strlen(s+1);
for(int i=1;i<=n;i++)
if(s[i]=='('||s[i]==')') cnt1++;
else cnt2++;
if(cnt1&1||cnt2&1) puts("No");
else
{
cnt1/=2,cnt2/=2;
for(int i=1;i<=n;i++)
if(s[i]=='('||s[i]==')')
{
if(cnt1>0) s[i]='(';
else s[i]=')';
cnt1--;
}
else
{
if(cnt2>0) s[i]='[';
else s[i]=']';
cnt2--;
}
for(int i=1;i<n/2;i++)
if(s[i]==s[i+1])
{
puts("No");
goto L;
}
for(int i=1;i<=n/2;i++)
if(s[i]=='('&&s[n-i+1]==')'||s[i]=='['&&s[n-i+1]==']');
else
{
puts("No");
goto L;
}
puts("Yes");L:;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
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: -100
Wrong Answer
time: 0ms
memory: 3812kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]