QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695524#7689. Flipping CardsUnlimitedz#WA 0ms3484kbC++171009b2024-10-31 20:12:422024-10-31 20:12:43

Judging History

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

  • [2024-10-31 20:12:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3484kb
  • [2024-10-31 20:12:42]
  • 提交

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;
//			}
//		}
//	}

	int cnt = 0;
	for(auto x : ans)
	{
		if(x == '(')cnt ++;
		else
		{
			if(cnt)cnt --;
		}
	}
	
	if(cnt)
	{
		cout << "impossible" << endl;
	}
	else
	{
		cout << ans << endl;
	}
}

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

详细

Test #1:

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

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'