QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#678910#7683. Hard Brackets ProblemDisplace_#WA 0ms3600kbC++14630b2024-10-26 16:24:342024-10-26 16:24:37

Judging History

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

  • [2024-10-26 16:24:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-10-26 16:24:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+86;
int T;
string s;

int main()
{
	cin>>T;
	while(T--)
	{
		string as;
		cin>>s;
		int sm=0;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='(') sm++;
			if(sm&&s[i]==')') sm--;
		}
		if(sm)
		{
			cout<<"impossible"<<endl;
			continue;
		}
		int i=0,j=0;
		while(i<s.size())
		{
			if(s[i]==')')
			{
				if(as[j]=='(') i++;
				else as[++j]=s[i],i++;
			}
			else if(s[i]=='(')
			{
				if(s[i+1]=='(') as[++j]=s[i],i++; 
				else as[++j]=s[i],i+=2;
			}
		}
		for(int i=0;i<=j;i++) cout<<as[i];
		cout<<endl;
	}
	return 0;
}

詳細信息

Test #1:

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

input:

3
((()))
(
)))()

output:


result:

wrong answer the answer string contains illegal characters (test case 1)