QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#627244 | #7894. Many Many Heads | adivse# | WA | 0ms | 3784kb | C++20 | 2.5kb | 2024-10-10 15:18:43 | 2024-10-10 15:18:44 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#define endl '\n'
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define rep2(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
template<typename... Args>
void bubu(Args... args) { cout << ":: "; ((cout << args << " "), ...); cout << endl; }
void bubu(vector<int> tem) { for (auto x : tem) cout << x << ' '; cout << endl; }
void kuaidu() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); }
inline int max(int a, int b) { if (a < b) return b; return a; }
inline int min(int a, int b) { if (a < b) return a; return b; }
using PII = pair<int, int>;
using i128 = __int128;
//=======================================================================
const int N = 1e5 + 10;
const int M = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 1e16;
int n, m, T;
//=======================================================================
int fan(char x) {
// if (x == ' ') return 2;
if (x == ')' || x == '(') return 1;
return 0;
}
int st[N];
int top;
signed main() {
kuaidu();
cin >> T;
while (T--) {
string s; cin >> s;
n = s.size();
s = ' ' + s;
// s = s + ' ';
int l1 = 0, l0 = 0; int r1 = 0, r0 = 0;
int fl = 1;
rep(i, 1, n - 3) {
int x1 = fan(s[i]), x2 = fan(s[i + 1]), x3 = fan(s[i + 2]), x4 = fan(s[i + 3]);
if (x1 == x2 and x1 == x3 and x1 == x4) {
fl = 0;
break;
}
}
if (fl == 0) {
cout << "No" << endl;
continue;
}
int ll = 0;
rep(i, 1, n - 1) {
if ((fan(s[i]) == fan(s[i + 1]) and i + 2 <= n and fan(s[i]) != fan(s[i + 2])) || ((fan(s[i]) == fan(s[i + 1])) and i == n - 1)) {
if (fan(s[i]) == 1) {
if (i % 2) l1++;
else r1++;
}
else {
if (i % 2) l0++;
else r0++;
}
i++;
}
else if (i + 2 <= n and fan(s[i]) == fan(s[i + 1]) and fan(s[i]) == fan(s[i + 2])) {
ll++;
i += 2;
}
}
if ((l1 + r1 + l0 + r0 >= 3) ||( l1 + r1 + l0 + r0 + ll >= 2)) cout << "No" << endl;
else cout << "Yes" << endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
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: 3784kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]