#include <stdio.h>
#define N 100000
int query(int i, int j) {
int x;
printf("? %d %d\n", i + 1, j + 1), fflush(stdout);
scanf("%d", &x);
return x;
}
int main() {
static int qu[N];
static char cc[N + 1];
int n, h, i, cnt;
scanf("%d%*d", &n);
cnt = 0;
for (i = 0; i < n; i++)
if (cnt == 0 || !query(qu[cnt - 1], i))
qu[cnt++] = i;
else
cc[qu[--cnt]] = '(', cc[i] = ')';
for (h = 0; h < cnt; h++)
cc[qu[h]] = h * 2 < cnt ? ')' : '(';
printf("! %s\n", cc), fflush(stdout);
return 0;
}
Compilation message
zagrade.c: In function 'query':
zagrade.c:9:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
9 | scanf("%d", &x);
| ^~~~~~~~~~~~~~~
zagrade.c: In function 'main':
zagrade.c:18:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | scanf("%d%*d", &n);
| ^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
4 ms |
200 KB |
Output is correct |
3 |
Correct |
9 ms |
200 KB |
Output is correct |
4 |
Correct |
11 ms |
200 KB |
Output is correct |
5 |
Correct |
7 ms |
200 KB |
Output is correct |
6 |
Correct |
10 ms |
200 KB |
Output is correct |
7 |
Correct |
10 ms |
200 KB |
Output is correct |
8 |
Correct |
10 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
10 ms |
284 KB |
Output is correct |
3 |
Correct |
10 ms |
200 KB |
Output is correct |
4 |
Correct |
10 ms |
200 KB |
Output is correct |
5 |
Correct |
4 ms |
200 KB |
Output is correct |
6 |
Correct |
7 ms |
200 KB |
Output is correct |
7 |
Correct |
10 ms |
268 KB |
Output is correct |
8 |
Correct |
6 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
418 ms |
412 KB |
Output is correct |
3 |
Correct |
730 ms |
460 KB |
Output is correct |
4 |
Correct |
627 ms |
456 KB |
Output is correct |
5 |
Correct |
856 ms |
336 KB |
Output is correct |
6 |
Correct |
939 ms |
352 KB |
Output is correct |
7 |
Correct |
896 ms |
552 KB |
Output is correct |
8 |
Correct |
592 ms |
480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
661 ms |
828 KB |
Output is correct |
3 |
Correct |
750 ms |
364 KB |
Output is correct |
4 |
Correct |
906 ms |
652 KB |
Output is correct |
5 |
Correct |
885 ms |
636 KB |
Output is correct |
6 |
Correct |
1010 ms |
548 KB |
Output is correct |
7 |
Correct |
524 ms |
596 KB |
Output is correct |
8 |
Correct |
673 ms |
552 KB |
Output is correct |