QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#627399 | #7894. Many Many Heads | hansue# | WA | 0ms | 3820kb | C++14 | 780b | 2024-10-10 15:48:49 | 2024-10-10 15:48:49 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N = 1e5;
int n, a[N + 3];
char s[N + 3];
bool isbra(char ch){
return ch == '(' || ch == ')' || ch == '[' || ch == ']';
}
void sol(){
n = 1;
while(isbra(s[n] = getchar()))
n++;
s[n] = '\0';
n--;
for(int i = 1; i <= n; i++)
a[i] = (s[i] == '(' || s[i] == ')')?0:1;
bool flag = true;
for(int i = 1; flag && i + i <= n; i++){
if(a[i] != a[n - i + 1])
flag = false;
if(i % 2 == 1 && a[i] != a[1])
flag = false;
if(i % 2 == 0 && a[i] == a[1])
flag = false;
}
printf("%s\n", flag?"Yes":"No");
}
int main(){
int T;
scanf("%d\n", &T);
while(T--)
sol();
return 0;
}
詳細信息
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: 3788kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]