# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1117602 |
2024-11-24T06:38:20 Z |
vjudge1 |
Match (CEOI16_match) |
C++17 |
|
1 ms |
336 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T, typename key = less_equal<T>>
using ordered_set = tree<T, null_type, key, rb_tree_tag, tree_order_statistics_node_update>;
void solve()
{
string s;
cin >> s;
ll n = s.size();
string b(n, '(');
stack<ll> st;
for (ll i = 0; i < n; i++)
if (st.empty()) b[i] = '(', st.push(i);
else if (s[st.top()] == s[i]) b[i] = ')', st.pop();
else b[i] = '(', st.push(i);
if (st.size() > 0) b = "-1";
cout << b << endl;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
ll t = 1;
// precomp();
// cin >> t;
for (ll cs = 1; cs <= t; cs++)
solve();
// cerr << "\nTime elapsed: " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |