# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223040 | Minnakhmetov | Match (CEOI16_match) | C++14 | 5 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
cin >> s;
int n = s.size();
vector<char> stk;
reverse(all(s));
string ans;
for (char c : s) {
if (stk.empty() || stk.back() != c) {
stk.push_back(c);
ans.push_back(')');
}
else {
stk.pop_back();
ans.push_back('(');
}
}
reverse(all(ans));
if (stk.empty()) {
cout << ans << "\n";
}
else {
cout << "-1\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |