Submission #1117824

#TimeUsernameProblemLanguageResultExecution timeMemory
1117824AtabayRajabliMatch (CEOI16_match)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define int long long using namespace std; const int sz = 1e5 + 5; string s, t; int n, last[26][sz]; void f(int l, int r) { if(l > r) return; int pos = last[s[l] - 'a'][r]; assert(pos >= 0); t[l] = '(', t[pos] = ')'; f(l + 1, pos - 1), f(pos + 1, r); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> s; n = s.size(); stack<int> st; for(int i = 0; i < n; i++) { if(!st.empty() && s[st.top()] == s[i]) { st.pop(); } else { st.push(i); } } if(!st.empty()) { cout << -1; return 0; } memset(last, -1, sizeof(last)); for(int i = 0; i < n; i++) { int l = s[i] - 'a'; last[l][i] = i; if(i == 0) continue; for(int j = 0; j < 26; j++) { last[j][i] = max(last[j][i - 1], last[j][i]); } } t.resize(n); f(0, n - 1); assert(0) cout << t; }

Compilation message (stderr)

match.cpp: In function 'int main()':
match.cpp:61:5: error: expected ';' before 'cout'
   61 |     cout << t;
      |     ^~~~