#include #include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint32_t N, i; cin >> N; string S; S.reserve(N), cin >> S; vector C(N); stack s; for (i = 0; i != N; ++i) switch (S[i]) { case '(': s.push(i); break; case ')': C[s.top()] = i + 1, C[i] = s.top() + 1; s.pop(); break; } for (i = 0; i != N; ++i) cout << C[i] << '\n'; return 0; }