#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int stk[MAXN], top;
int q(int a, int b) {
cout << '?' << ' ' << a << ' ' << b << endl;
int x;
cin >> x;
return x;
}
int main() {
int n, m;
cin >> n >> m;
string s;
for (int i = 1; i <= n; ++i) {
s = s + ' ';
if (top == 0 || !q(stk[top], i)) {
stk[++top] = i;
} else {
s[stk[top--] - 1] = '(';
s[i - 1] = ')';
}
}
for (int i = 1; i <= top / 2; ++i)
s[stk[i] - 1] = ')';
for (int i = top / 2 + 1; i <= top; ++i)
s[stk[i] - 1] = '(';
cout << '!' << ' ' << s;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
364 KB |
Output is correct |
3 |
Correct |
10 ms |
364 KB |
Output is correct |
4 |
Correct |
11 ms |
512 KB |
Output is correct |
5 |
Correct |
10 ms |
364 KB |
Output is correct |
6 |
Correct |
8 ms |
492 KB |
Output is correct |
7 |
Correct |
8 ms |
364 KB |
Output is correct |
8 |
Correct |
10 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
10 ms |
364 KB |
Output is correct |
3 |
Correct |
8 ms |
364 KB |
Output is correct |
4 |
Correct |
9 ms |
364 KB |
Output is correct |
5 |
Correct |
10 ms |
364 KB |
Output is correct |
6 |
Correct |
11 ms |
364 KB |
Output is correct |
7 |
Correct |
10 ms |
492 KB |
Output is correct |
8 |
Correct |
10 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1160 ms |
1208 KB |
Output is correct |
3 |
Correct |
1503 ms |
1168 KB |
Output is correct |
4 |
Correct |
1656 ms |
1252 KB |
Output is correct |
5 |
Correct |
1589 ms |
1356 KB |
Output is correct |
6 |
Correct |
1611 ms |
2112 KB |
Output is correct |
7 |
Correct |
1649 ms |
1568 KB |
Output is correct |
8 |
Correct |
1722 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1556 ms |
1760 KB |
Output is correct |
3 |
Correct |
1522 ms |
1252 KB |
Output is correct |
4 |
Correct |
1816 ms |
1296 KB |
Output is correct |
5 |
Correct |
1705 ms |
1956 KB |
Output is correct |
6 |
Correct |
1925 ms |
1152 KB |
Output is correct |
7 |
Correct |
1613 ms |
1324 KB |
Output is correct |
8 |
Correct |
1987 ms |
1444 KB |
Output is correct |