QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#570395 | #7894. Many Many Heads | mhw# | WA | 0ms | 3600kb | C++23 | 813b | 2024-09-17 15:37:20 | 2024-09-17 15:37:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
void solve()
{
string s;
cin >> s;
int n = s.size(), f1 = 0, f2 = 0;
for (int i = 0; i < n; i++)
{
if (s[i] == '(' || s[i] == ')') s[i] = '0';
else s[i] = '1';
}
int l1 = -1, l2 = -1;
for (int i = 0; i < n; i++)
{
if (s[i] == '0')
{
if ((i - l1) & 1) f1++;
l1 = i;
}
else
{
if ((i - l2) & 1) f2++;
l2 = i;
}
}
if (f1 >= 3 || f2 >= 3) cout << "No\n";
else cout << "Yes\n";
}
signed main()
{
ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
int t;
cin >> t;
while(t--) solve();
}
/*
4
()([()])
([])([()])
([()])([()])
[]()
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
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: 3564kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]