QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#383417 | #7894. Many Many Heads | hlzy_awei | WA | 0ms | 3704kb | C++14 | 1.0kb | 2024-04-09 13:50:43 | 2024-04-09 13:50:43 |
Judging History
answer
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
string s;
ll n;
ll x1,x2;
int main()
{
cin>>n;
while(n--)
{
cin>>s;
x1=0,x2=0;
for(ll i=0;i<s.length();i++)
{
if(s[i]==')')
s[i]='(';
if(s[i]==']')
s[i]='[';
if(s[i]=='(')
x1++;
else
x2++;
}
if(s.length()%2||x1%2||x2%2)
cout<<"No\n";
else
{
for(ll i=1;i<s.length()/2;i++)
{
if(s[i]==s[i-1])
{
cout<<"No\n";
goto ed;
}
}
for(ll i=s.length()/2;i<s.length();i++)
{
if(s[i]!=s[s.length()-i-1])
{
cout<<"No\n";
goto ed;
}
}
cout<<"Yes\n";
ed:;
}
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3696kb
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: 3704kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]