# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
604417 |
2022-07-25T06:10:14 Z |
Aleee |
Match (CEOI16_match) |
C++14 |
|
0 ms |
212 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define endl '\n'
#define forn(i, l, n) for (int i = l; i < int(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
int main() // Ale C.
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("output.txt", "w", stdout);
string str;
cin >> str;
stack<char> st;
string ans = "(";
st.push(str[0]);
int test = 1;
forn(i, 1, str.length())
{
if (test < 0)
break;
if (st.empty())
{
ans += "(";
st.push(str[i]);
test++;
continue;
}
if (st.top() != str[i])
{
ans += "(";
st.push(str[i]);
test++;
}
else
{
ans += ")";
st.pop();
test--;
}
}
cout << (test == 0 ? ans : "-1");
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |