QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619409#7894. Many Many Headsqz2003Compile Error//C++20757b2024-10-07 14:07:452024-10-07 14:07:46

Judging History

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

  • [2024-10-07 14:07:46]
  • 评测
  • [2024-10-07 14:07:45]
  • 提交

answer

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int t;
int a[100005];
int main() {
//	ios::sync_with_stdio(0);
//	cin.tie(0);
	cin>>t;
	while(t--){
		bool ok=1;
		stack<bool> l,r;
		string s;
		cin>>s;
		int len=s.size();
		for(int i=0;i<len;i++){
			if(s[i]=='('||s[i]==')'){
				a[i]=0;
			}
			else{
				a[i]=1;
			}
		}
		for(int i=1;i<len-1;i++){
			if(a[i]==a[i-1]&&a[i]==a[i+1]){
				ok=0;
				break;
			}
		}
		int f1=0,f0=0;
		for(int i=0;i<len-1;i++){
			if(a[i]==a[i+1]){
				if(a[i]==1){
					f1++;
				}
				else{
					f0++;
				}
			}
			if(f1>=2||f0>=2||f1+f2>=3){
				ok=0;
				break;
			}
		}
		if(ok){
			cout<<"Yes\n";
		}
		else{
			cout<<"No\n";
		}
	}
	return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:40:45: error: ‘f2’ was not declared in this scope; did you mean ‘f0’?
   40 |                         if(f1>=2||f0>=2||f1+f2>=3){
      |                                             ^~
      |                                             f0