QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#818978 | #7894. Many Many Heads | OIer_kzc# | WA | 0ms | 1452kb | C++20 | 774b | 2024-12-18 11:22:54 | 2024-12-18 11:22:55 |
Judging History
answer
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <vector>
#include <algorithm>
#define LOG(FMT...) fprintf(stderr, FMT)
#define eb emplace_back
using namespace std;
typedef long long LL;
constexpr int N = 400005, M = 1000005;
constexpr int INF = 0x3f3f3f3f;
int n; char s[N];
bool chk() {
for (int i = 1; i < n; ++i) {
if (s[i] == s[i - 1]) {
return false;
}
}
for (int i = 0; i < n; ++i) {
if (s[i] != s[2 * n - i - 1]) {
return false;
}
}
return true;
}
int main() {
int task;
for (scanf("%d", &task); task--; ) {
scanf("%s", s), n = strlen(s);
for (int i = 0; i < n; ++i) {
s[i] = (s[i] == '(' || s[i] == ')');
}
n /= 2;
puts(chk() ? "Yes" : "No");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 1452kb
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: 1424kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]