QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#692182 | #7894. Many Many Heads | ljljljlj# | WA | 3ms | 3836kb | C++20 | 853b | 2024-10-31 13:59:41 | 2024-10-31 13:59:42 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
using i64 = long long;
const int inf = 1e9;
void solve()
{
string s;
cin >> s;
int pre1 = 0, pre2 = 0, cnt = 0;
for (int i = 0; i < s.size(); i++)
{
if (s[i] == '(' || s[i] == ')')
pre1 += 1;
else
pre2 += 1;
if ((pre1 == 0 && pre2 == 4) || (pre2 == 0 && pre1 == 4))
{
cout << "No\n";
return;
}
if (pre1 != 0 && pre2 != 0 && (pre1 % 2 == 0) && (pre2 % 2 == 0))
cnt++;
}
if (cnt > 1)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
int main()
{
ios::sync_with_stdio(false), cin.tie(0);
int T = 1;
cin >> T;
while (T--)
solve();
// system("pause");
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3496kb
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: 0
Accepted
time: 0ms
memory: 3836kb
input:
2 (([([[([ ]]))])]])]
output:
Yes No
result:
ok 2 token(s): yes count is 1, no count is 1
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 3616kb
input:
15134 ][ )( )([[ [)([ )][) ]])( ([]([] ]]))][ [([](] ()[))] ][(]]( ([()[) ()[](( [)([)( ]]([[)]] )[()])]] ))[](([] ](([((]] ))[)][)[ [)])([(] [()[]))[ )][(]()] [[((]()] ((]])[[) ])(](]]) )]]()[]( ([)[])]) [[)[()]( ([[)[[() [[)([])) [)[[)[() ))[(([)( ()][)[](]] [()]([[([[ )[]))][)][ )]([]([(][ [])])(...
output:
Yes Yes Yes Yes Yes Yes No No Yes Yes Yes Yes No No No No No No Yes No No No No No No No No Yes No No No No No No No No No No No No No No No No Yes No No No No No No No No No No No No No No No No Yes No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No N...
result:
wrong answer expected YES, found NO [7th token]