QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#314659 | #7894. Many Many Heads | ucup-team1087 | WA | 0ms | 3656kb | C++14 | 1.7kb | 2024-01-26 02:27:32 | 2024-01-26 02:27:33 |
Judging History
answer
#include <iostream>
#include <iomanip>
#include <cmath>
#include <climits>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <set>
#include <map>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
const int N = 1e5 + 1;
char str[N + 1];
bool c[CHAR_MAX], a[N];
void solve() {
scanf("%s", str + 1);
int len = (int)strlen(str + 1);
for (int i = 1; i <= len; ++i) {
a[i] = c[str[i]];
}
vector<bool> stk;
for (int i = 1; i <= len; ++i) {
if (!stk.empty() && stk.back() == a[i]) {
stk.pop_back();
} else {
stk.push_back(a[i]);
}
}
if (!stk.empty()) {
puts("No");
return ;
}
for (int i = 1; i <= len - 2; ++i) {
if (a[i] == a[i + 1] && a[i + 1] == a[i + 2]) {
puts("No");
return ;
}
}
int cnt0 = 0, cnt1 = 0;
for (int i = 1; i <= len - 1; ++i) {
if (a[i] == 0 && a[i + 1] == 0) {
if (++cnt0 >= 2) {
puts("No");
return ;
}
} else if (a[i] == 1 && a[i + 1] == 1) {
if (++cnt1 >= 2) {
puts("No");
return ;
}
}
++i;
}
puts("Yes");
}
int main(int argc, const char * argv[]) {
c['['] = c[']'] = false;
c['('] = c[')'] = true;
int T;
scanf("%d", &T);
while (T--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3656kb
input:
6 )) ((() [()] ()[()]() ([()]) ([])([])
output:
Yes No Yes No Yes Yes
result:
wrong answer expected NO, found YES [6th token]