vector<int> circ[105]; bool vis[105], ans[105]; int cnt = 0;
boolcheck(){ int cnt1 = 0, cnt2 = 0; for (int i = 1; i <= n; ++i) { cnt1 += (ans[i] == 0), cnt2 += ans[i]; if (cnt1 < cnt2) return0; } return1; }
voiddfs(int u){ if (u == cnt + 1) { if (check()) { for (int i = 1; i <= n; ++i) putchar('(' + ans[i]); exit(0); } return; } int len = circ[u].size(); if (!(len ^ 2)) { ans[circ[u][0]] = 0, ans[circ[u][1]] = 1; dfs(u + 1); } else { for (int i = 0; i ^ len; ++i) ans[circ[u][i]] = i & 1; dfs(u + 1); for (int i = 0; i ^ len; ++i) ans[circ[u][i]] = !(i & 1); dfs(u + 1); } }
intmain(){ scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &p[i]); for (int i = 1; i <= n; ++i) { if (vis[i] == 0) { cnt += 1; int cur = i; do { circ[cnt].push_back(cur); vis[cur] = 1; cur = p[cur]; } while (cur != i); } } dfs(1); return0; }