QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#748918 | #7894. Many Many Heads | surenjamts# | WA | 0ms | 3592kb | C++20 | 666b | 2024-11-14 21:57:45 | 2024-11-14 21:57:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define S second
#define F first
void solve(){
string s;
cin >> s;
int n = s.size();
vector<int> stk;
int cnt = 0;
for(int i = 0; i < n; i++){
int num = 0;
if(s[i] == '[' || s[i] == ']') num = 1;
if(stk.empty()) cnt++, stk.push_back(num);
else {
if(stk.back() == num) stk.pop_back();
else stk.push_back(num);
}
}
//cout << cnt << endl;
if(cnt > 1) cout << "No\n";
else cout << "Yes\n";
}
int main(){
int t; cin >> t; while(t--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3488kb
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: 3592kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]