QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#314212 | #7894. Many Many Heads | hy233 | WA | 0ms | 3760kb | C++14 | 736b | 2024-01-25 14:25:08 | 2024-01-25 14:25:09 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1000005;
const ll mod=998244353;
inline int rd()
{
int x=0; bool f=1;
char ch=getchar();
for(;ch<'0'||ch>'9';ch=getchar())
if(ch=='-') f=0;
for(;ch>='0'&&ch<='9';ch=getchar())
x=x*10+(ch^48);
return f?x:-x;
}
#define ck(x) ((x)=='('||(x)==')')
char s[N];
int main()
{
int t=rd();
while(t--)
{
scanf("%s",s+1);
int n=strlen(s+1);
if(n&1)
{
printf("No\n");
continue;
}
bool bb=1;
for(int i=1;i<=n/2&&bb;i++)
if(ck(s[i])!=ck(s[n-i+1]))
bb=0;
for(int i=2;i<=n/2&&bb;i++)
if(ck(s[i])==ck(s[i-1]))
bb=0;
if(bb)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3760kb
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: 3724kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]