QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#556374 | #7894. Many Many Heads | HTensor | WA | 4ms | 3636kb | C++17 | 1.6kb | 2024-09-10 17:24:50 | 2024-09-10 17:24:54 |
Judging History
answer
#include <bits/stdc++.h>
#define dd(x) cout << #x << "\n"
#define d(x) cout << #x << ": " << x << "\n"
using namespace std;
#define int long long
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using a3 = array<int, 3>;
const int inf = 0x3f3f3f3f3f3f3f3fLL;
void solve() {
string str; cin >> str;
// int n = str.size();
vector<int> ans;
int a1 = 0, a2 = 0, lst = -1;
for(auto c : str) {
if(c == '[' || c == ']') {
if(!a1) ++a1;
else {
--a1;
if(lst == 1) {
ans.push_back(1); ans.push_back(1); ans.push_back(1);
break;
}
lst = 1;
}
} else {
if(!a2) ++a2;
else {
--a2;
if(lst == 0) {
ans.push_back(1); ans.push_back(1); ans.push_back(1);
break;
}
lst = 0;
}
}
if(!a1 && !a2) {
ans.push_back((c == '[' || c == ']') ? 1 : 0);
lst = -1;
}
}
// assert(ans.size() != 0);
if(ans.size() > 2) {
cout << "No\n";
} else if(ans.size() == 1) {
cout << "Yes\n";
} else {
cout << (ans[0] == ans[1] ? "No\n" : "Yes\n");
}
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
int T; cin >> T;
while(T--) solve();
return 0;
}
/*
6
))
((()
[()]
()[()]()
([()])
([])([])
1
([])[()]
*/
Details
Tip: Click on the bar to expand more detailed information
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: 0
Accepted
time: 0ms
memory: 3596kb
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: 4ms
memory: 3636kb
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 No No No No No No No Yes No Yes No No No No No Yes No No No No Yes No No No No No Yes No Yes No No No No No No No No No No No No No No No No No No Yes No No No No No No No No ...
result:
wrong answer expected YES, found NO [36th token]