QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#314268 | #7894. Many Many Heads | wdw | WA | 3ms | 3788kb | C++14 | 1.7kb | 2024-01-25 15:08:58 | 2024-01-25 15:08:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define int long long
const int N=1205+5;
const double eps=1e-10;
const int mod=1e9;
#define endl '\n'
void solve() {
string s;
cin>>s;
int f=0;
int f2=0;
for(int i=0;i<s.size();i++){
if(s[i]==')'||s[i]=='('){
f2=0;
f++;
if(f==3){
cout<<"No"<<endl;
return;
}
}else if(s[i]=='['||s[i]==']'){
f=0;
f2++;
if(f2==3){
cout<<"No"<<endl;
return;
}
}
}
vector<int>a(s.size()+5);
int x=1;
int f1=0;
for(int i=0;i<s.size();i++){
if(s[i]==')'||s[i]=='('){
a[x]++;
if(a[x]==3){
cout<<"No"<<endl;
return;
}
}else{
if(f1==0){
f1=1;
x++;
}else{
f1=0;
x--;
}
}
}
int f3=0;
int x2=1;
vector<int>a2(s.size()+5);
for(int i=0;i<s.size();i++){
if(s[i]=='['||s[i]==']'){
a2[x2]++;
if(a2[x2]==3){
cout<<"No"<<endl;
return;
}
}else{
if(f3==0){
f3=1;
x2++;
}else{
f3=0;
x2--;
}
}
}
cout<<"Yes"<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
// cout<<fixed<<setprecision(2);
int T=1;
cin>>T;
while(T--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3784kb
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: 3584kb
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: 3ms
memory: 3788kb
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 No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No N...
result:
wrong answer expected YES, found NO [36th token]