QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#466757#7683. Hard Brackets Problemyurongyi#Compile Error//C++14643b2024-07-08 09:29:272024-07-08 09:29:28

Judging History

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

  • [2024-07-08 09:29:28]
  • 评测
  • [2024-07-08 09:29:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
string s, ans;
int cnt1 = 0, cnt2 = 0;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int Cases;
	cin >> Cases;
	while(Cases--){
		cin >> s;
		ans.clear();
		cnt1 = cnt2 = 0;
		for(auto c : s){
			if(c == '('){
				while(cnt2){
					ans.push_back(')');
					cnt2--;
				}
				cnt1++;
			}
			else{
				if(cnt1){
					ans.push_back('(');
					cnt1--, cnt2++;
				}
				else
					ans.push_back(')');
			}
//			cout << cnt1 << endl;
		}
		if(cnt1)
			cout << "impossible\n";
		else
			cout << ans << "\n";
	}
	return 0;
}
1

Details

answer.code:40:1: error: expected unqualified-id before numeric constant
   40 | 1
      | ^