QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#314657 | #7894. Many Many Heads | ucup-team1087 | WA | 0ms | 3628kb | C++14 | 1.6kb | 2024-01-26 02:26:00 | 2024-01-26 02:26:01 |
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 cnt = 0;
for (int i = 1; i <= len - 1; ++i) {
if (a[i] == a[i + 1]) {
if (++cnt >= 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: 100
Accepted
time: 0ms
memory: 3628kb
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: 3624kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]