QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#755724#7894. Many Many Headsyumz#WA 0ms3776kbC++14896b2024-11-16 17:57:022024-11-16 17:57:02

Judging History

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

  • [2024-11-16 17:57:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3776kb
  • [2024-11-16 17:57:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
int a[1000010];
stack<int>q;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t;
	cin >> t;
	while( t-- ){
		int ans = 0;
		while( !q.empty() )q.pop();
		string s;
		cin >> s;
		int n = s.length();
		s = " "+s;
		for(int i = 1;i <= n; ++i){
			if( s[i] == '(' || s[i] == ')' )a[i] = 0;
			else a[i] = 1;
		}
		q.push(1);
		int bj = 0;
		for(int i = 2;i <= n; ++i){
			int f = 0;
			if( !q.empty() )f = q.top(),q.pop();
			if( f == 0 ){
				q.push(i);
				continue;
			}
			if( a[f] != a[i] )q.push(f),q.push(i);
			else if( q.size() == 0 ) {
				ans++;
				for(int j = f,k = i;j+1 <= k-1; ++j,k--){
					if(a[j] == a[j+1])bj = 0;
				}
			}
		}
		if( ans >= 3 )bj = 0;
		if( bj )cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3776kb

input:

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

output:

No
No
No
No
No
No

result:

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