QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#278018 | #7894. Many Many Heads | ucup-team1338# | WA | 1ms | 3432kb | C++20 | 787b | 2023-12-07 10:48:26 | 2023-12-07 10:48:26 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef long long ll;
int val(char c)
{
if (c == '(' || c == ')')
return 0;
return 1;
}
void solve()
{
string s;
cin >> s;
int n = s.length();
s = '\0' + s;
for (int i = 1; i <= n / 2; ++i)
{
if (val(s[i]) != val(s[n - i + 1]))
{
cout << "No\n";
return;
}
if (i > 1 && val(s[i]) == val(s[i - 1]))
{
cout << "No\n";
return;
}
}
cout << "Yes\n";
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while (T--)
solve();
// solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3432kb
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: 3420kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]