QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627195#7894. Many Many HeadsTytytony#WA 7ms7732kbC++231.1kb2024-10-10 15:10:362024-10-10 15:10:38

Judging History

你现在查看的是最新测评结果

  • [2024-10-10 15:10:38]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:7732kb
  • [2024-10-10 15:10:36]
  • 提交

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(m[perml]%2==1||perml==0) perml++;
				else perml--;
				Mm=max(Mm,perml);
			}
			if(a[i]=='['||a[i]==']'){
				m[perml]++;
				if(s[persl]%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==1;i++){
			if(s[i]>2){
				tf=0;
				break;
			}
		}
		for(int i=0;i<=Mm&&tf==1;i++){
			if(m[i]>2){
				tf=0;
				break;
			}
		}
//		cout<<Ms<<" "<<Mm<<endl;
		if(tf) cout<<"Yes\n";
		else cout<<"No\n";
	} 
	return 0;

}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5668kb

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: 7732kb

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: 7ms
memory: 5684kb

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]