QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#750065 | #7894. Many Many Heads | WedonotLikeStudying# | WA | 2ms | 3828kb | C++20 | 617b | 2024-11-15 12:29:10 | 2024-11-15 12:29:10 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,j,k) for (int i=(j);i<=(k);++i)
#define dep(i,j,k) for (int i=(j);i>=(k);--i)
#define MAXN 100000
using namespace std;
string s;
int a[MAXN+5];
void solve() {
cin>>s;
int n=s.size();
s=' '+s;
rep(i,1,n) {
if (s[i]=='('||s[i]==')') a[i]=0;
else a[i]=1;
}
int ans=0;
rep(i,1,n) {
if (a[i]==a[i+1]) ++ans;
}
if (ans<=2) cout<<"Yes\n";
else cout<<"No\n";
}
int main() {
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;
cin>>t;
while (t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
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: 3752kb
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: 2ms
memory: 3828kb
input:
15134 ][ )( )([[ [)([ )][) ]])( ([]([] ]]))][ [([](] ()[))] ][(]]( ([()[) ()[](( [)([)( ]]([[)]] )[()])]] ))[](([] ](([((]] ))[)][)[ [)])([(] [()[]))[ )][(]()] [[((]()] ((]])[[) ])(](]]) )]]()[]( ([)[])]) [[)[()]( ([[)[[() [[)([])) [)[[)[() ))[(([)( ()][)[](]] [()]([[([[ )[]))][)][ )]([]([(][ [])])(...
output:
Yes Yes Yes Yes Yes No Yes No Yes Yes No Yes No No No Yes No No Yes Yes No Yes No No No No Yes No No No No No No No No Yes No No No No No No Yes No No Yes Yes No No No Yes No No No No No No No No No Yes No No 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 No No No ...
result:
wrong answer expected YES, found NO [6th token]