Submission #604417

#TimeUsernameProblemLanguageResultExecution timeMemory
604417AleeeMatch (CEOI16_match)C++14
0 / 100
0 ms212 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...