QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#543152#7894. Many Many HeadsNew_Folder#WA 0ms3616kbC++14757b2024-09-01 14:29:532024-09-01 14:29:53

Judging History

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

  • [2024-09-01 14:29:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-09-01 14:29:53]
  • 提交

answer

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define int long long
//#define pi 3.1415926
typedef long long ll;
using namespace std;
int mod=998244353;

int fp(int a,int b){
	int ans=1;
	while(b){
		if(b&1) ans*=a,ans%=mod;
		a*=a,a%=mod;
		b>>=1;
	}
	return ans;
}

void solve(){
	string str;
	cin>>str;bool ans=1;
	int len=str.length();
	bool flag=0;
	if(str[0]=='('||str[0]==')') flag=1;
	for(int i=1;i<=len/2-1;i++){
		if(str[i]=='('||str[i]==')'){
			if(flag) ans=0;
			else flag=1;
		}
		else{
			if(!flag) ans=0;
			else flag=0;
		}
	}
	if(ans) cout<<"Yes\n";
	else cout<<"No\n";
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int t;cin>>t;while(t--) 
	solve();
	return 0;
}	

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

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

output:

No
No

result:

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