QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#418394 | #7894. Many Many Heads | zzzyzzz# | WA | 1ms | 3824kb | C++17 | 945b | 2024-05-23 13:35:35 | 2024-05-23 13:35:37 |
Judging History
answer
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=1e5+7;
typedef pair<int,int> PII;
char str[N];
int n;
bool check() {
int n=strlen(str+1);
bool flag=false;
int a=0,b=0;
int c=0;
for(int i=1;i<=n;i++) {
if(str[i]==')'||str[i]=='(') {
if(c) {
b++;
if(b==4) flag=true;
}else {
a++;
if(a==4) flag=true;
}
}else {
if(c==1) b=0,c=0;
else c=1;
}
}
return flag;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;cin>>T;
while(T--) {
scanf("%s",str+1);
n=strlen(str+1);
bool flag=false;
flag=flag|check();
for(int i=1;i<=n;i++) {
if(str[i]==')') str[i]=']';
else if(str[i]=='(') str[i]='[';
else if(str[i]==']') str[i]=')';
else if(str[i]=='[') str[i]='(';
}
flag=flag|check();
if(!flag) cout<<"Yes"<<'\n';
else cout<<"No"<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3824kb
input:
6 )) ((() [()] ()[()]() ([()]) ([])([])
output:
Yes Yes Yes Yes Yes Yes
result:
wrong answer expected NO, found YES [2nd token]