QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#410114 | #7894. Many Many Heads | huangbrother# | WA | 0ms | 3560kb | C++17 | 1.1kb | 2024-05-13 13:36:21 | 2024-05-13 13:36:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int a[100010];
vector<pair<int,int>>v;
int main(){
int t;
cin>>t;
while(t--){
string s;
cin>>s;
int res1=0,res2=0;
for(int i=0;i<s.size();i++){
if(s[i]=='['||s[i]==']')res2++;
else res1++;
}
int k1=res1,k2=res2;
for(int i=0;i<s.size();i++){
if(s[i]=='['||s[i]==']'){
if(k2>res2/2)k2--,s[i]='[';
else k2--,s[i]=']';
}
else {
if(k1>res1/2)s[i]='(';
else s[i]=')';
k1--;
}
}
int flag=0;
for(int i=1;i<s.size();i++){
if(s[i-1]=='['&&s[i]==')')s[i-1]=']';
if(s[i-1]=='('&&s[i]==']')s[i-1]=')';
}
for(int i=1;i<s.size()/2;i++){
if(s[i]==s[i-1])flag=1;
}
for(int i=s.size()-2;i>=s.size()/2;i--){
if(s[i]==s[i+1])flag=1;
}
if(flag)cout<<"No\n";
else cout<<"Yes\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
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: 3460kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]