QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#695473 | #7689. Flipping Cards | Unlimitedz# | WA | 0ms | 3604kb | C++17 | 866b | 2024-10-31 20:06:25 | 2024-10-31 20:07:26 |
Judging History
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'