QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619226#7894. Many Many HeadstsaiWA 0ms3788kbC++14978b2024-10-07 13:33:542024-10-07 13:33:54

Judging History

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

  • [2024-10-07 13:33:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3788kb
  • [2024-10-07 13:33:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 +50;
int trans[N];
int cnt[3];
int booll[3]={0};
void solve(){
	stack<int>st;
	string s;
	cin>>s;
	booll[1]=booll[2]=0;
  	for(int i = 1; i <= s.length(); i++) trans[i] = (s[i-1] == '(' || s[i-1] == ')')? 1 : 2;  
  	cnt [0] = cnt[1] = cnt[2] = 0;
  	int last = 0;
	for(int i = 1; i <= s.length(); i++){
	    if(!st.empty()){
	      	if(trans[i] == st.top()){
	        	st.pop();last=trans[i];cnt[trans[i]]=1;
	      	}else{
	      		booll[last]=1;
	      		last=0;
	        	st.push(trans[i]);
	      	} 
	        if((cnt[1]>=1&&booll[1]==1)||(cnt[2]>=1&&booll[2]==1)) return printf("No"), void();
	    }else {
			st.push(trans[i]);
	    	booll[last]=1;
		}
	}
    if((cnt[1]>=1&&booll[1]==1)||(cnt[2]>=1&&booll[2]==1)) return printf("No"), void();	
  	printf("Yes");
}
int main(){ 
	int t;
	scanf("%d",&t);
	while(t--){
		solve();
    if(t) printf("\n");
	}	
	return 0;
}

詳細信息

Test #1:

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

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

input:

2
(([([[([
]]))])]])]

output:

No
No

result:

wrong answer expected YES, found NO [1st token]