QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#278875 | #7894. Many Many Heads | ucup-team1508# | WA | 1ms | 3468kb | C++20 | 876b | 2023-12-07 21:47:12 | 2023-12-07 21:47:13 |
Judging History
answer
#include<bits/stdc++.h>
#define F(i, a, b) for(int i = a; i <= b; i ++)
#define Fd(i, a, b) for(int i = a; i >= b; i --)
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
const int N = 105;
int n;
void sol() {
string s; cin >> s; n = s.size();
s = " " + s;
F(i, 1, n) {
if(s[i] == '(' || s[i] == ')') s[i] = '(';
else s[i] = '[';
}
if(s[n / 2] != s[n / 2 + 1]) {
cout << "No\n";
return;
}
F(i, 2, n / 2) if(s[i] == s[i - 1]) {
cout << "No\n";
return;
}
F(i, n / 2 + 1, n - 1) if(s[i] == s[i + 1]) {
cout << "No\n";
return;
}
cout << "Yes\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t; cin >> t;
F(i, 1, t) sol();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3384kb
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: 1ms
memory: 3468kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]