QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#638027#7894. Many Many HeadsEtha#WA 4ms3640kbC++141.1kb2024-10-13 14:41:212024-10-13 14:41:21

Judging History

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

  • [2024-10-13 14:41:21]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3640kb
  • [2024-10-13 14:41:21]
  • 提交

answer

#include<iostream>
#include<cstdio>
#define N 100100
using namespace std;
int a[N];
int main(){
	int t;
	cin>>t;
	string str;
	while(t--){
		cin>>str;
		int len = str.length();
		for (int i=0;i<len;i++){
			if(str[i]=='('||str[i]==')') a[i+1]=1;
			else a[i+1]=2;
		}
		int flag=0,ff=0;
		if(len==2&&a[1]==a[2]){
			cout<<"Yes"<<endl;
			continue;
		}
		if(a[1]==a[2]) ff++;
		if(a[len]==a[len-1]) ff++;
		if(ff==2){
			cout<<"No"<<endl;
			continue;
		}
		else if(a[1]==a[2]){
			for(int i=3;i<=len/2+1;i++){
				if(a[i]!=a[len+3-i]||a[i]==a[i-1]) flag=1;
			}
			if(!flag) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
			continue;
		}
		else if(a[len]==a[len-1]){
			for(int i=1;i<=len/2-1;i++){
				if(a[i]!=a[len-1-i]||a[i]==a[i-1]) flag=1;
			}
			if(a[len-1]==a[len-2]) flag=1;
			if(!flag) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
			continue;
		}else{
			for(int i=1;i<=len/2;i++){
				if(a[i]!=a[len+1-i]||a[i]==a[i-1]) flag=1;
			}
			if(!flag) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
		
		
		
		
	} 
	return 0;
}


详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3640kb

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

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

input:

15134
][
)(
)([[
[)([
)][)
]])(
([]([]
]]))][
[([](]
()[))]
][(]](
([()[)
()[]((
[)([)(
]]([[)]]
)[()])]]
))[](([]
](([((]]
))[)][)[
[)])([(]
[()[]))[
)][(]()]
[[((]()]
((]])[[)
])(](]])
)]]()[](
([)[])])
[[)[()](
([[)[[()
[[)([]))
[)[[)[()
))[(([)(
()][)[](]]
[()]([[([[
)[]))][)][
)]([]([(][
[])])(...

output:

Yes
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
Yes
Yes
No
No
No
No
No
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
No
N...

result:

wrong answer expected YES, found NO [3rd token]