QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#418394#7894. Many Many Headszzzyzzz#WA 1ms3824kbC++17945b2024-05-23 13:35:352024-05-23 13:35:37

Judging History

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

  • [2024-05-23 13:35:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2024-05-23 13:35:35]
  • 提交

answer

#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;
const int N=1e5+7;
typedef pair<int,int> PII;
char str[N];
int n;

bool check() {
	int n=strlen(str+1);
	bool flag=false;
	int a=0,b=0;
	int c=0;
	for(int i=1;i<=n;i++) {
		if(str[i]==')'||str[i]=='(') {
			if(c) {
				b++;
				if(b==4) flag=true;
			}else {
				a++;
				if(a==4) flag=true;
			}
		}else {
			if(c==1) b=0,c=0;
			else c=1;
		}
	}
	
	return flag;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int T;cin>>T;
	while(T--) {
		scanf("%s",str+1);
		n=strlen(str+1);
		
		bool flag=false;
		
		flag=flag|check();
		for(int i=1;i<=n;i++) {
			if(str[i]==')') str[i]=']';
			else if(str[i]=='(') str[i]='[';
			else if(str[i]==']') str[i]=')';
			else if(str[i]=='[') str[i]='(';
		}
		flag=flag|check();
		
		if(!flag) cout<<"Yes"<<'\n';
		else cout<<"No"<<'\n';
	}
	
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3824kb

input:

6
))
((()
[()]
()[()]()
([()])
([])([])

output:

Yes
Yes
Yes
Yes
Yes
Yes

result:

wrong answer expected NO, found YES [2nd token]