QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#695473#7689. Flipping CardsUnlimitedz#WA 0ms3604kbC++17866b2024-10-31 20:06:252024-10-31 20:07:26

Judging History

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

  • [2024-10-31 20:07:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-10-31 20:06:25]
  • 提交

answer

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define fixed(s) fixed<<setprecision(12)<<s
//#define int long long
 
using namespace std;
 
typedef pair<int, int> PII;
typedef long long ll;
typedef pair<ll, PII> PLII;

void solve()
{
	string s;
	cin >> s;
	int n = s.size();
	vector<int> sum(n + 2);
	int f = 0;
	string ans = s;
	s = " " + s;
	
	for(int i = 1; i <= n; i ++)
	{
		if(s[i] == '(')sum[i] = 1;
		else sum[i] = -1;
		sum[i] += sum[i - 1];
	}
	
	for(int i = 1; i <= n; i ++)
	{
		if(s[i] == '(')
		{
			if(sum[n] - sum[i - 1] > 0)
			{
				f = 1;
				break;
			}
		}
	}
	
	if(f)
	{
		cout << "impossible" << endl;
	}
	else
	{
		cout << ans << endl;
	}
}

int main()
{
	IOS
	int _;
	cin >> _;
	while(_ --)
	{
		solve();
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
3 6
5 2
4 7
6 4
2 8

output:

3
6
5
2
4

result:

wrong answer 1st numbers differ - expected: '6', found: '3'