QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#363211 | #7894. Many Many Heads | OobugoO | WA | 8ms | 3744kb | C++20 | 1.0kb | 2024-03-23 19:37:18 | 2024-03-23 19:37:19 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
typedef long long ll;
int get(char c) {
if (c == '#') return 0x3f3f3f3f;
return c == '(' || c == ')';
}
void solve() {
std::string s;
std::cin >> s;
char pre = '#';
int num = 0;
std::vector<char> st(1, '#');
for (auto x : s) {
if (get(x) == get(st.back()))
st.pop_back();
else
st.push_back(x);
if (st.size() == 1) {
if (get(pre) == get(x)) {
std::cout << "No\n";
return;
}
pre = x;
num++;
}
}
if (st.size() == 1 && num <= 2) {
std::cout << "Yes\n";
} else {
std::cout << "No\n";
}
}
int main(){
#ifdef Onlion_Judge
freopen("IO/input.in", "r", stdin);
freopen("IO/output.out", "w", stdout);
// freopen("E:\\save work\\data\\4.in", "w", stdout);
#endif
int t = 1;
std::cin >> t;
while (t--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3520kb
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: 3744kb
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: 8ms
memory: 3472kb
input:
15134 ][ )( )([[ [)([ )][) ]])( ([]([] ]]))][ [([](] ()[))] ][(]]( ([()[) ()[](( [)([)( ]]([[)]] )[()])]] ))[](([] ](([((]] ))[)][)[ [)])([(] [()[]))[ )][(]()] [[((]()] ((]])[[) ])(](]]) )]]()[]( ([)[])]) [[)[()]( ([[)[[() [[)([])) [)[[)[() ))[(([)( ()][)[](]] [()]([[([[ )[]))][)][ )]([]([(][ [])])(...
output:
Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes No Yes No Yes No No Yes Yes No Yes No No Yes No Yes Yes No No Yes No No No No Yes No No No No No No Yes No Yes Yes Yes No No No Yes No No No No Yes No No No Yes Yes Yes No Yes No No No No No No Yes No No No No No No No No No No Yes Yes No No No No No No...
result:
wrong answer expected NO, found YES [45th token]