제출 #222986

#제출 시각아이디문제언어결과실행 시간메모리
222986MinnakhmetovMatch (CEOI16_match)C++14
0 / 100
5 ms384 KiB
#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; string ans; for (int i = 0; i < n; i++) { if (stk.empty() || stk.back() != s[i]) { stk.push_back(s[i]); ans.push_back('('); } else { vector<char> stk_cp = stk; stk_cp.push_back(s[i]); for (int j = i + 1; j < n; j++) { if (stk_cp.empty() || stk_cp.back() != s[i]) { stk_cp.push_back(s[i]); } else { stk_cp.pop_back(); } } if (stk_cp.empty()) { stk.push_back(s[i]); ans.push_back('('); } else { stk.pop_back(); ans.push_back(')'); } } } if (stk.empty()) { cout << ans << "\n"; } else { cout << "-1\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...