QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#627047 | #7894. Many Many Heads | Tytytony# | WA | 11ms | 5684kb | C++23 | 1.1kb | 2024-10-10 14:35:06 | 2024-10-10 14:35:12 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 1000010
using namespace std;
char a[N];
int s[N]={0},m[N]={0},cnt;
int persl,perml,Ms,Mm,tf;
void clean(){
for(int i=0;i<=cnt+2;i++){
s[i]=0,m[i]=0;
}
persl=0,perml=0;
Ms=0,Mm=0;
tf=1;
}
int main(){
int T;
cin>>T;
while(T--){
cin>>a;
cnt=0;
for(int i=0;a[i]!=0;i++) cnt++;
clean();
for(int i=0;a[i]!=0;i++){
if(a[i]=='('||a[i]==')'){
s[persl]++;
if(s[persl]%2==1||perml==0) perml++;
else perml--;
Mm=max(Mm,perml);
}
if(a[i]=='['||a[i]==']'){
m[perml]++;
if(m[perml]%2==1||persl==0) persl++;
else persl--;
Ms=max(Ms,persl);
}
}
// for(int i=0;i<10;i++) cout<<s[i]<<" ";
// cout<<endl;
// for(int i=0;i<10;i++) cout<<m[i]<<" ";
// cout<<endl;
for(int i=0;i<=Ms&&tf;i++){
if(s[i]>2){
tf=0;
break;
}
}
for(int i=0;i<=Mm&&tf;i++){
if(m[i]>2){
tf=0;
break;
}
}
if(tf) cout<<"Yes\n";
else cout<<"No\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5684kb
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: 1ms
memory: 5636kb
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: 11ms
memory: 5676kb
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 Yes No No No No No No No No No Yes Yes No No No No No No No No No No No No Yes Yes No No No No No No No No No Yes No No No No No No No No No No Yes No No No No No No No No No ...
result:
wrong answer expected YES, found NO [43rd token]