QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#394851#7894. Many Many Headsucup-team3294#WA 0ms3880kbC++23819b2024-04-20 20:38:002024-04-20 20:38:00

Judging History

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

  • [2024-04-20 20:38:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3880kb
  • [2024-04-20 20:38:00]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define PII pair<int,int>
#define x first
#define y second
using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
int c[N],d[N];
void solve() {
     string a;
     cin>>a;
     int n=a.size();
     a=" "+a;
     int count1=0,count2=0,num1=0,num2=0;
     for(int i=1;i<=n;i++){
     	if(a[i]=='('||a[i]==')') c[++num1]=i;
     	else d[++num2]=i;
	 }
	 for(int i=2;i<=num1;i++){
	 	if((c[i]-c[i-1])&1){
	 	   i++;
		   count1++;	
		}
	 }
	 for(int i=2;i<=num2;i++){
	 	if((d[i]-d[i-1])&1){
	 	   i++;
		   count2++;	
		}
	 }
	 if(count1>=2||count2>=2){
	 	cout<<"No\n";
	 }else cout<<"Yes\n";
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int T=1;
	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: 3880kb

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

input:

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

output:

No
No

result:

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